Skip to content

Commit

Permalink
new logs + remove caching for getting users
Browse files Browse the repository at this point in the history
  • Loading branch information
zkokelj committed Dec 19, 2024
1 parent 05b9147 commit 8f34663
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tools/walletextension/storage/storage_with_cache.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package storage

import (
"fmt"

"github.com/ethereum/go-ethereum/log"
"github.com/ten-protocol/go-ten/go/common/viewingkey"
"github.com/ten-protocol/go-ten/tools/walletextension/cache"
Expand Down Expand Up @@ -71,19 +73,20 @@ func (s *UserStorageWithCache) RemoveSessionKey(userID []byte) error {

// AddAccount adds an account to a user and invalidates the cache for the userID
func (s *UserStorageWithCache) AddAccount(userID []byte, accountAddress []byte, signature []byte, signatureType viewingkey.SignatureType) error {
fmt.Println("TESTING: adding account to cosmos db for user", userID, "account", accountAddress)
err := s.storage.AddAccount(userID, accountAddress, signature, signatureType)
if err != nil {
return err
}

fmt.Println("TESTING: account added to cosmos db for user", userID, "account", accountAddress)
s.cache.Remove(userID)
return nil
}

// GetUser retrieves a user from the cache or underlying storage
func (s *UserStorageWithCache) GetUser(userID []byte) (*wecommon.GWUser, error) {
return cache.WithCache(s.cache, &cache.Cfg{Type: cache.LongLiving}, userID, func() (*wecommon.GWUser, error) {
return s.storage.GetUser(userID)
})
return s.storage.GetUser(userID)
}

// GetEncryptionKey delegates to the underlying storage
Expand Down

0 comments on commit 8f34663

Please sign in to comment.