From 699b534416f17f124075c8c6345689b7f0a6085b Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Wed, 7 Sep 2022 15:32:16 +0400 Subject: [PATCH] [#1763] node/netmap: Write log message about parsed NewEpoch event There is a need to have the ability to track NeoFS timeline on storage nodes. Epochs tick on notifications receipt, so the most obvious way to know about received epochs is logging the events. Wrap `morphEvent.ParseNewEpoch` event parser into function which writes log message about new epoch number. Signed-off-by: Leonard Lyubich --- cmd/neofs-node/morph.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/cmd/neofs-node/morph.go b/cmd/neofs-node/morph.go index 54d0bccbf..a7d6a480d 100644 --- a/cmd/neofs-node/morph.go +++ b/cmd/neofs-node/morph.go @@ -6,6 +6,7 @@ import ( "fmt" "github.com/nspcc-dev/neo-go/pkg/core/block" + "github.com/nspcc-dev/neo-go/pkg/core/state" "github.com/nspcc-dev/neo-go/pkg/util" morphconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/morph" "github.com/nspcc-dev/neofs-node/pkg/core/netmap" @@ -211,7 +212,16 @@ func listenMorphNotifications(c *cfg) { }) })) - setNetmapNotificationParser(c, newEpochNotification, netmapEvent.ParseNewEpoch) + setNetmapNotificationParser(c, newEpochNotification, func(src *state.ContainedNotificationEvent) (event.Event, error) { + res, err := netmapEvent.ParseNewEpoch(src) + if err == nil { + c.log.Info("new epoch event from sidechain", + zap.Uint64("number", res.(netmapEvent.NewEpoch).EpochNumber()), + ) + } + + return res, err + }) registerNotificationHandlers(c.cfgNetmap.scriptHash, lis, c.cfgNetmap.parsers, c.cfgNetmap.subscribers) registerNotificationHandlers(c.cfgContainer.scriptHash, lis, c.cfgContainer.parsers, c.cfgContainer.subscribers)