From dbf3a2f2fb0ff813a536310567abaa636ed465bb Mon Sep 17 00:00:00 2001 From: Pavel Karpy Date: Fri, 12 Nov 2021 18:19:05 +0300 Subject: [PATCH] [#971] *: Add optional parameters to container morph client calls Adapt all container wrapper calls to new structures. Signed-off-by: Pavel Karpy --- cmd/neofs-node/container.go | 7 ++++++- pkg/innerring/blocktimer.go | 5 ++++- .../processors/container/process_container.go | 21 +++++++++++++++++-- .../processors/container/process_eacl.go | 9 +++++++- .../processors/netmap/process_epoch.go | 8 ++++++- 5 files changed, 44 insertions(+), 6 deletions(-) diff --git a/cmd/neofs-node/container.go b/cmd/neofs-node/container.go index f1be678bb..92a70e418 100644 --- a/cmd/neofs-node/container.go +++ b/cmd/neofs-node/container.go @@ -221,7 +221,12 @@ func (w *morphLoadWriter) Put(a containerSDK.UsedSpaceAnnouncement) error { zap.Uint64("size", a.UsedSpace()), ) - return w.cnrMorphClient.AnnounceLoad(a, w.key) + prm := wrapper.AnnounceLoadPrm{} + + prm.SetAnnouncement(a) + prm.SetReporter(w.key) + + return w.cnrMorphClient.AnnounceLoad(prm) } func (*morphLoadWriter) Close() error { diff --git a/pkg/innerring/blocktimer.go b/pkg/innerring/blocktimer.go index dfeba744f..a6faf352c 100644 --- a/pkg/innerring/blocktimer.go +++ b/pkg/innerring/blocktimer.go @@ -95,7 +95,10 @@ func newEpochTimer(args *epochTimerArgs) *timer.BlockTimer { return } - err := args.cnrWrapper.StopEstimation(epochN - 1) + prm := container.StopEstimationPrm{} + prm.SetEpoch(epochN - 1) + + err := args.cnrWrapper.StopEstimation(prm) if err != nil { args.l.Warn("can't stop epoch estimation", zap.Uint64("epoch", epochN), diff --git a/pkg/innerring/processors/container/process_container.go b/pkg/innerring/processors/container/process_container.go index df6f06383..244ebf239 100644 --- a/pkg/innerring/processors/container/process_container.go +++ b/pkg/innerring/processors/container/process_container.go @@ -6,6 +6,8 @@ import ( "errors" "fmt" + "github.com/nspcc-dev/neofs-node/pkg/morph/client/container/wrapper" + "github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neo-go/pkg/network/payload" "github.com/nspcc-dev/neofs-api-go/v2/refs" @@ -121,12 +123,21 @@ func (cp *Processor) approvePutContainer(ctx *putContainerContext) { var err error + prm := wrapper.PutPrm{} + + prm.SetContainer(e.Container()) + prm.SetKey(e.PublicKey()) + prm.SetSignature(e.Signature()) + prm.SetToken(e.SessionToken()) + prm.SetName(ctx.name) + prm.SetZone(ctx.zone) + if nr := e.NotaryRequest(); nr != nil { // put event was received via Notary service err = cp.cnrClient.Morph().NotarySignAndInvokeTX(nr.MainTransaction) } else { // put event was received via notification service - err = cp.cnrClient.Put(e.Container(), e.PublicKey(), e.Signature(), e.SessionToken(), ctx.name, ctx.zone) + err = cp.cnrClient.Put(prm) } if err != nil { cp.log.Error("could not approve put container", @@ -225,12 +236,18 @@ func (cp *Processor) checkDeleteContainer(e *containerEvent.Delete) error { func (cp *Processor) approveDeleteContainer(e *containerEvent.Delete) { var err error + prm := wrapper.DeletePrm{} + + prm.SetCID(e.ContainerID()) + prm.SetSignature(e.Signature()) + prm.SetToken(e.SessionToken()) + if nr := e.NotaryRequest(); nr != nil { // delete event was received via Notary service err = cp.cnrClient.Morph().NotarySignAndInvokeTX(nr.MainTransaction) } else { // delete event was received via notification service - err = cp.cnrClient.Delete(e.ContainerID(), e.Signature(), e.SessionToken()) + err = cp.cnrClient.Delete(prm) } if err != nil { cp.log.Error("could not approve delete container", diff --git a/pkg/innerring/processors/container/process_eacl.go b/pkg/innerring/processors/container/process_eacl.go index c75ae1116..1b3064d29 100644 --- a/pkg/innerring/processors/container/process_eacl.go +++ b/pkg/innerring/processors/container/process_eacl.go @@ -85,12 +85,19 @@ func (cp *Processor) checkSetEACL(e container.SetEACL) error { func (cp *Processor) approveSetEACL(e container.SetEACL) { var err error + prm := wrapper.PutEACLPrm{} + + prm.SetTable(e.Table()) + prm.SetKey(e.PublicKey()) + prm.SetSignature(e.Signature()) + prm.SetToken(e.SessionToken()) + if nr := e.NotaryRequest(); nr != nil { // setEACL event was received via Notary service err = cp.cnrClient.Morph().NotarySignAndInvokeTX(nr.MainTransaction) } else { // setEACL event was received via notification service - err = cp.cnrClient.PutEACL(e.Table(), e.PublicKey(), e.Signature(), e.SessionToken()) + err = cp.cnrClient.PutEACL(prm) } if err != nil { cp.log.Error("could not approve set EACL", diff --git a/pkg/innerring/processors/netmap/process_epoch.go b/pkg/innerring/processors/netmap/process_epoch.go index cad1fd6f4..1a8b34e23 100644 --- a/pkg/innerring/processors/netmap/process_epoch.go +++ b/pkg/innerring/processors/netmap/process_epoch.go @@ -4,6 +4,7 @@ import ( "github.com/nspcc-dev/neofs-node/pkg/innerring/processors/audit" "github.com/nspcc-dev/neofs-node/pkg/innerring/processors/governance" "github.com/nspcc-dev/neofs-node/pkg/innerring/processors/settlement" + "github.com/nspcc-dev/neofs-node/pkg/morph/client/container/wrapper" netmapEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/netmap" "go.uber.org/zap" ) @@ -36,8 +37,13 @@ func (np *Processor) processNewEpoch(ev netmapEvent.NewEpoch) { return } + prm := wrapper.StartEstimationPrm{} + + prm.SetEpoch(epoch - 1) + prm.SetHash(ev.TxHash()) + if epoch > 0 { // estimates are invalid in genesis epoch - err = np.containerWrp.StartEstimation(epoch - 1) + err = np.containerWrp.StartEstimation(prm) if err != nil { np.log.Warn("can't start container size estimation",