diff --git a/client/opts.go b/client/opts.go index 60a38943..2afd17f4 100644 --- a/client/opts.go +++ b/client/opts.go @@ -27,6 +27,9 @@ type ( key *ecdsa.PrivateKey session *session.Token bearer *token.BearerToken + // network magic is a client config, but it's convenient to copy it here (see v2MetaHeaderFromOpts) + // the value remains the same between calls + netMagic uint64 } clientOptions struct { @@ -41,6 +44,8 @@ type ( // // default is false parseNeoFSErrors bool + + netMagic uint64 } v2SessionReqInfo struct { @@ -56,6 +61,8 @@ func (c *Client) defaultCallOptions() *callOptions { version: version.Current(), ttl: 2, key: c.opts.key, + // copy client's static value is a bit overhead, but it is the easiest way at the time of feature intro + netMagic: c.opts.netMagic, } } @@ -115,6 +122,8 @@ func v2MetaHeaderFromOpts(options *callOptions) *v2session.RequestMetaHeader { meta.SetSessionToken(options.session.ToV2()) + meta.SetNetworkMagic(options.netMagic) + return meta } @@ -210,3 +219,10 @@ func WithNeoFSErrorParsing() Option { opts.parseNeoFSErrors = true } } + +// WithNetworkMagic returns option to specify NeoFS network magic. +func WithNetworkMagic(magic uint64) Option { + return func(opts *clientOptions) { + opts.netMagic = magic + } +} diff --git a/go.mod b/go.mod index aa785bbc..be659121 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/mr-tron/base58 v1.2.0 github.com/nspcc-dev/hrw v1.0.9 github.com/nspcc-dev/neo-go v0.98.0 - github.com/nspcc-dev/neofs-api-go/v2 v2.11.1 + github.com/nspcc-dev/neofs-api-go/v2 v2.11.2-0.20220114101721-227a871a04ac github.com/nspcc-dev/neofs-crypto v0.3.0 github.com/stretchr/testify v1.7.0 go.uber.org/zap v1.18.1 diff --git a/go.sum b/go.sum index 7fbcae75..166500a1 100644 --- a/go.sum +++ b/go.sum @@ -177,8 +177,8 @@ github.com/nspcc-dev/neo-go v0.73.1-pre.0.20200303142215-f5a1b928ce09/go.mod h1: github.com/nspcc-dev/neo-go v0.98.0 h1:yyW4sgY88/pLf0949qmgfkQXzRKC3CI/WyhqXNnwMd8= github.com/nspcc-dev/neo-go v0.98.0/go.mod h1:E3cc1x6RXSXrJb2nDWXTXjnXk3rIqVN8YdFyWv+FrqM= github.com/nspcc-dev/neofs-api-go/v2 v2.11.0-pre.0.20211201134523-3604d96f3fe1/go.mod h1:oS8dycEh8PPf2Jjp6+8dlwWyEv2Dy77h/XhhcdxYEFs= -github.com/nspcc-dev/neofs-api-go/v2 v2.11.1 h1:SVqc523pZsSaS9vnPS1mm3VV6b6xY0gvdA0uYJ/GWZQ= -github.com/nspcc-dev/neofs-api-go/v2 v2.11.1/go.mod h1:oS8dycEh8PPf2Jjp6+8dlwWyEv2Dy77h/XhhcdxYEFs= +github.com/nspcc-dev/neofs-api-go/v2 v2.11.2-0.20220114101721-227a871a04ac h1:65C4z7pybLT2HjtY96abZj6kbgVp34AbrApn5DD+ZxY= +github.com/nspcc-dev/neofs-api-go/v2 v2.11.2-0.20220114101721-227a871a04ac/go.mod h1:oS8dycEh8PPf2Jjp6+8dlwWyEv2Dy77h/XhhcdxYEFs= github.com/nspcc-dev/neofs-crypto v0.2.0/go.mod h1:F/96fUzPM3wR+UGsPi3faVNmFlA9KAEAUQR7dMxZmNA= github.com/nspcc-dev/neofs-crypto v0.2.3/go.mod h1:8w16GEJbH6791ktVqHN9YRNH3s9BEEKYxGhlFnp0cDw= github.com/nspcc-dev/neofs-crypto v0.3.0 h1:zlr3pgoxuzrmGCxc5W8dGVfA9Rro8diFvVnBg0L4ifM=