From 2a3a6cc0ba9c963d3113cecd3fcc1b8d269eb49f Mon Sep 17 00:00:00 2001 From: Pavel Karpy Date: Tue, 12 Oct 2021 15:57:57 +0300 Subject: [PATCH] [#873] node: Use dynamic notary deposit duration Signed-off-by: Pavel Karpy --- cmd/neofs-node/morph.go | 7 ++++++- cmd/neofs-node/netmap.go | 3 --- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cmd/neofs-node/morph.go b/cmd/neofs-node/morph.go index c4cfda682..7190026f1 100644 --- a/cmd/neofs-node/morph.go +++ b/cmd/neofs-node/morph.go @@ -133,9 +133,14 @@ func makeNotaryDeposit(c *cfg) (util.Uint256, error) { return util.Uint256{}, fmt.Errorf("could not calculate notary deposit: %w", err) } + epochDur, err := c.cfgNetmap.wrapper.EpochDuration() + if err != nil { + return util.Uint256{}, fmt.Errorf("could not get current epoch duration: %w", err) + } + return c.cfgMorph.client.DepositNotary( depositAmount, - c.cfgMorph.notaryDepositDuration+notaryDepositExtraBlocks, + uint32(epochDur)+notaryDepositExtraBlocks, ) } diff --git a/cmd/neofs-node/netmap.go b/cmd/neofs-node/netmap.go index 206e34211..73ad33a73 100644 --- a/cmd/neofs-node/netmap.go +++ b/cmd/neofs-node/netmap.go @@ -7,7 +7,6 @@ import ( netmapSDK "github.com/nspcc-dev/neofs-api-go/pkg/netmap" netmapV2 "github.com/nspcc-dev/neofs-api-go/v2/netmap" netmapGRPC "github.com/nspcc-dev/neofs-api-go/v2/netmap/grpc" - morphconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/morph" "github.com/nspcc-dev/neofs-node/pkg/core/netmap" "github.com/nspcc-dev/neofs-node/pkg/morph/event" netmapEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/netmap" @@ -148,8 +147,6 @@ func initNetmapService(c *cfg) { }) if c.cfgMorph.notaryEnabled { - c.cfgMorph.notaryDepositDuration = morphconfig.Notary(c.appCfg).Duration() - addNewEpochAsyncNotificationHandler(c, func(ev event.Event) { _, err := makeNotaryDeposit(c) if err != nil {