[#971] *: Add optional parameters to container morph client calls

Adapt all container wrapper calls to new
structures.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2021-11-12 18:19:05 +03:00 committed by Alex Vanin
parent af33dd65b2
commit dbf3a2f2fb
5 changed files with 44 additions and 6 deletions

View file

@ -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 {

View file

@ -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),

View file

@ -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",

View file

@ -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",

View file

@ -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",