Skip to content

Commit

Permalink
morph,node/object/put: support "strict" meta-data policy
Browse files Browse the repository at this point in the history
According to nspcc-dev/neofs-api#309, "strict" must wait
for meta-data handling on the contract-side and every PUT request is responded
only with transaction acceptance.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
  • Loading branch information
carpawell committed Dec 11, 2024
1 parent 863a404 commit 95afd93
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
8 changes: 6 additions & 2 deletions pkg/morph/client/container/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,21 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
)

// SubmitObjectPut puts object meta information.
// SubmitObjectPut puts object meta information. With awaitTX it blocks until
// TX is accepted in chain or is expired.
//
// Returns any error encountered that caused the saving to interrupt.
func (c *Client) SubmitObjectPut(meta []byte, sigs [][]byte) error {
func (c *Client) SubmitObjectPut(awaitTX bool, meta []byte, sigs [][]byte) error {
if len(meta) == 0 || len(sigs) == 0 {
return errNilArgument
}

var prm client.InvokePrm
prm.SetMethod(submitObjectPutMethod)
prm.SetArgs(meta, sigs)
if awaitTX {
prm.Await()
}

err := c.client.Invoke(prm)
if err != nil {
Expand Down
11 changes: 10 additions & 1 deletion pkg/services/object/put/distributed.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,16 @@ func (t *distributedTarget) Close() (oid.ID, error) {
t.metaMtx.RLock()
defer t.metaMtx.RUnlock()

err = t.cnrClient.SubmitObjectPut(t.objSharedMeta, t.collectedSignatures)
var await bool
switch t.metainfoConsistencyAttr {
// TODO: there was no constant in SDK at the code creation moment
case "strict":
await = true
default:
await = false
}

err = t.cnrClient.SubmitObjectPut(await, t.objSharedMeta, t.collectedSignatures)
if err != nil {
t.placementIterator.log.Info("submitting meta information", zap.Stringer("oid", id), zap.Error(err))
}
Expand Down

0 comments on commit 95afd93

Please sign in to comment.