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 <[email protected]>
  • Loading branch information
carpawell committed Dec 12, 2024
1 parent 4eac112 commit 72c8470
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 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
15 changes: 13 additions & 2 deletions pkg/services/object/put/distributed.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,22 @@ func (t *distributedTarget) Close() (oid.ID, error) {
return oid.ID{}, err
}

if t.localNodeInContainer && (t.metainfoConsistencyAttr == "strict" || t.metainfoConsistencyAttr == "optimistic") {
if t.localNodeInContainer && t.metainfoConsistencyAttr != "" {
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
case "optimistic":
await = false
default:
return id, nil
}

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

0 comments on commit 72c8470

Please sign in to comment.