[#85] pool: use non-pointer client inside wrapper

Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
Denis Kirillov 2022-03-29 14:12:15 +03:00 committed by LeL
parent 9e8e12f6ae
commit 97c8274dc0

View file

@ -53,7 +53,7 @@ type client interface {
// clientWrapper is used by default, alternative implementations are intended for testing purposes only. // clientWrapper is used by default, alternative implementations are intended for testing purposes only.
type clientWrapper struct { type clientWrapper struct {
client *sdkClient.Client client sdkClient.Client
key ecdsa.PrivateKey key ecdsa.PrivateKey
} }
@ -86,14 +86,20 @@ func newWrapper(prm wrapperPrm) (*clientWrapper, error) {
prmInit.SetDefaultPrivateKey(prm.key) prmInit.SetDefaultPrivateKey(prm.key)
prmInit.SetResponseInfoCallback(prm.responseInfoCallback) prmInit.SetResponseInfoCallback(prm.responseInfoCallback)
var c sdkClient.Client res := &clientWrapper{key: prm.key}
c.Init(prmInit)
res.client.Init(prmInit)
var prmDial sdkClient.PrmDial var prmDial sdkClient.PrmDial
prmDial.SetServerURI(prm.address) prmDial.SetServerURI(prm.address)
prmDial.SetTimeout(prm.timeout) 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) { func (c *clientWrapper) balanceGet(ctx context.Context, prm PrmBalanceGet) (*accounting.Decimal, error) {