diff --git a/pkg/morph/client/constructor.go b/pkg/morph/client/constructor.go index 760bf4a6..8d54d5ef 100644 --- a/pkg/morph/client/constructor.go +++ b/pkg/morph/client/constructor.go @@ -84,7 +84,7 @@ func New(key *keys.PrivateKey, endpoint string, opts ...Option) (*Client, error) if cfg.singleCli != nil { return &Client{ - cache: initClientCache(), + cache: newClientCache(), singleClient: blankSingleClient(cfg.singleCli, wallet.NewAccountFromPrivateKey(key), cfg), }, nil } @@ -92,17 +92,17 @@ func New(key *keys.PrivateKey, endpoint string, opts ...Option) (*Client, error) endpoints := append(cfg.extraEndpoints, endpoint) return &Client{ + cache: newClientCache(), multiClient: &multiClient{ - cfg: *cfg, - account: wallet.NewAccountFromPrivateKey(key), - endpoints: endpoints, - clients: make(map[string]*Client, len(endpoints)), - sharedCache: initClientCache(), + cfg: *cfg, + account: wallet.NewAccountFromPrivateKey(key), + endpoints: endpoints, + clients: make(map[string]*Client, len(endpoints)), }, }, nil } -func initClientCache() cache { +func newClientCache() cache { c, _ := lru.New(100) // returns error only if size is negative return cache{ txHeights: c, diff --git a/pkg/morph/client/multi.go b/pkg/morph/client/multi.go index 54cf0edd..1534165e 100644 --- a/pkg/morph/client/multi.go +++ b/pkg/morph/client/multi.go @@ -15,8 +15,6 @@ type multiClient struct { sharedNotary *notary // notary config needed for single client construction - sharedCache cache - endpoints []string clientsMtx sync.Mutex clients map[string]*Client @@ -48,7 +46,7 @@ func (x *multiClient) createForAddress(addr string) (*Client, error) { sCli.notary = x.sharedNotary c = &Client{ - cache: x.sharedCache, + cache: newClientCache(), singleClient: sCli, } x.clients[addr] = c