From 27fc4d6e01f7eade4a89c374644e4c50724a57dd Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Mon, 23 Nov 2020 15:58:39 +0300 Subject: [PATCH] [#193] network/cache: Support client options in ClientCache.Get Signed-off-by: Leonard Lyubich --- pkg/network/cache/client.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pkg/network/cache/client.go b/pkg/network/cache/client.go index 136b84dea..007fec847 100644 --- a/pkg/network/cache/client.go +++ b/pkg/network/cache/client.go @@ -27,10 +27,8 @@ func NewSDKClientCache() *ClientCache { } } -// Get function returns existing client or creates a new one. Consider passing -// connection options to specify details for client, but don't forget that two -// different set of options should provide two different clients. -func (c *ClientCache) Get(key *ecdsa.PrivateKey, address string) (*client.Client, error) { +// Get function returns existing client or creates a new one. +func (c *ClientCache) Get(key *ecdsa.PrivateKey, address string, opts ...client.Option) (*client.Client, error) { id := uniqueID(key, address) c.mu.RLock() @@ -52,7 +50,7 @@ func (c *ClientCache) Get(key *ecdsa.PrivateKey, address string) (*client.Client return cli, nil } - cli, err := client.New(key, client.WithAddress(address)) + cli, err := client.New(key, append(opts, client.WithAddress(address))...) if err != nil { return nil, err }