forked from TrueCloudLab/frostfs-node
[#108] cmd/neofs-node: Listen new epoch notifications from morph
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
0dab4b7581
commit
07fe49088c
5 changed files with 108 additions and 0 deletions
|
@ -4,6 +4,7 @@ import (
|
|||
"github.com/nspcc-dev/neofs-api-go/v2/netmap"
|
||||
netmapGRPC "github.com/nspcc-dev/neofs-api-go/v2/netmap/grpc"
|
||||
crypto "github.com/nspcc-dev/neofs-crypto"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
||||
netmapTransportGRPC "github.com/nspcc-dev/neofs-node/pkg/network/transport/netmap/grpc"
|
||||
netmapService "github.com/nspcc-dev/neofs-node/pkg/services/netmap"
|
||||
"github.com/pkg/errors"
|
||||
|
@ -34,3 +35,27 @@ func bootstrapNode(c *cfg) {
|
|||
err := c.cfgNetmap.wrapper.AddPeer(c.cfgNodeInfo.info)
|
||||
fatalOnErr(errors.Wrap(err, "bootstrap error"))
|
||||
}
|
||||
|
||||
func addNetmapNotificationHandler(c *cfg, sTyp string, h event.Handler) {
|
||||
typ := event.TypeFromString(sTyp)
|
||||
|
||||
if c.cfgNetmap.subscribers == nil {
|
||||
c.cfgNetmap.subscribers = make(map[event.Type][]event.Handler, 1)
|
||||
}
|
||||
|
||||
c.cfgNetmap.subscribers[typ] = append(c.cfgNetmap.subscribers[typ], h)
|
||||
}
|
||||
|
||||
func setNetmapNotificationParser(c *cfg, sTyp string, p event.Parser) {
|
||||
typ := event.TypeFromString(sTyp)
|
||||
|
||||
if c.cfgNetmap.parsers == nil {
|
||||
c.cfgNetmap.parsers = make(map[event.Type]event.Parser, 1)
|
||||
}
|
||||
|
||||
c.cfgNetmap.parsers[typ] = p
|
||||
}
|
||||
|
||||
func addNewEpochNotificationHandler(c *cfg, h event.Handler) {
|
||||
addNetmapNotificationHandler(c, newEpochNotification, h)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue