@@ -5,24 +5,22 @@ import (
55
66 "github.com/nspcc-dev/neofs-node/pkg/morph/client"
77 fschaincontracts "github.com/nspcc-dev/neofs-node/pkg/morph/contracts"
8+ "github.com/nspcc-dev/neofs-sdk-go/container"
89 cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
910)
1011
1112// PutPrm groups parameters of Put operation.
1213type PutPrm struct {
13- cnr []byte
14- key []byte
15- sig []byte
16- token []byte
17- name string
18- zone string
19- enableMetaOnChain bool
14+ cnr container.Container
15+ key []byte
16+ sig []byte
17+ token []byte
2018
2119 client.InvokePrmOptional
2220}
2321
24- // SetContainer sets container data .
25- func (p * PutPrm ) SetContainer (cnr [] byte ) {
22+ // SetContainer sets container.
23+ func (p * PutPrm ) SetContainer (cnr container. Container ) {
2624 p .cnr = cnr
2725}
2826
@@ -41,22 +39,7 @@ func (p *PutPrm) SetToken(token []byte) {
4139 p .token = token
4240}
4341
44- // SetName sets native name.
45- func (p * PutPrm ) SetName (name string ) {
46- p .name = name
47- }
48-
49- // SetZone sets zone.
50- func (p * PutPrm ) SetZone (zone string ) {
51- p .zone = zone
52- }
53-
54- // EnableMeta enables meta-on-chain.
55- func (p * PutPrm ) EnableMeta () {
56- p .enableMetaOnChain = true
57- }
58-
59- // Put saves binary container with its session token, key and signature
42+ // Put saves container with its session token, key and signature
6043// in NeoFS system through Container contract call.
6144//
6245// Returns calculated container identifier and any error
@@ -69,7 +52,12 @@ func (c *Client) Put(p PutPrm) (cid.ID, error) {
6952 var prm client.InvokePrm
7053 prm .SetMethod (fschaincontracts .CreateContainerMethod )
7154 prm .InvokePrmOptional = p .InvokePrmOptional
72- prm .SetArgs (p .cnr , p .sig , p .key , p .token , p .name , p .zone , p .enableMetaOnChain )
55+
56+ domain := p .cnr .ReadDomain ()
57+ metaAttr := p .cnr .Attribute ("__NEOFS__METAINFO_CONSISTENCY" )
58+ metaEnabled := metaAttr == "optimistic" || metaAttr == "strict"
59+ cnrBytes := p .cnr .Marshal ()
60+ prm .SetArgs (cnrBytes , p .sig , p .key , p .token , domain .Name (), domain .Zone (), metaEnabled )
7361
7462 // no magic bugs with notary requests anymore, this operation should
7563 // _always_ be notary signed so make it one more time even if it is
@@ -83,9 +71,9 @@ func (c *Client) Put(p PutPrm) (cid.ID, error) {
8371 if err = c .client .Invoke (prm ); err != nil {
8472 return cid.ID {}, fmt .Errorf ("could not invoke method (%s): %w" , putMethod , err )
8573 }
86- return cid .NewFromMarshalledContainer (p . cnr ), nil
74+ return cid .NewFromMarshalledContainer (cnrBytes ), nil
8775 }
8876 return cid.ID {}, fmt .Errorf ("could not invoke method (%s): %w" , fschaincontracts .CreateContainerMethod , err )
8977 }
90- return cid .NewFromMarshalledContainer (p . cnr ), nil
78+ return cid .NewFromMarshalledContainer (cnrBytes ), nil
9179}
0 commit comments