From 97c8274dc0bfbf54ffe0a2e414edfc24264adc2c Mon Sep 17 00:00:00 2001 From: Denis Kirillov Date: Tue, 29 Mar 2022 14:12:15 +0300 Subject: [PATCH] [#85] pool: use non-pointer client inside wrapper Signed-off-by: Denis Kirillov --- pool/pool.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/pool/pool.go b/pool/pool.go index 80f24236..c63eeed5 100644 --- a/pool/pool.go +++ b/pool/pool.go @@ -53,7 +53,7 @@ type client interface { // clientWrapper is used by default, alternative implementations are intended for testing purposes only. type clientWrapper struct { - client *sdkClient.Client + client sdkClient.Client key ecdsa.PrivateKey } @@ -86,14 +86,20 @@ func newWrapper(prm wrapperPrm) (*clientWrapper, error) { prmInit.SetDefaultPrivateKey(prm.key) prmInit.SetResponseInfoCallback(prm.responseInfoCallback) - var c sdkClient.Client - c.Init(prmInit) + res := &clientWrapper{key: prm.key} + + res.client.Init(prmInit) var prmDial sdkClient.PrmDial prmDial.SetServerURI(prm.address) prmDial.SetTimeout(prm.timeout) - return &clientWrapper{client: &c, key: prm.key}, c.Dial(prmDial) + err := res.client.Dial(prmDial) + if err != nil { + return nil, fmt.Errorf("client dial: %w", err) + } + + return res, nil } func (c *clientWrapper) balanceGet(ctx context.Context, prm PrmBalanceGet) (*accounting.Decimal, error) {