forked from TrueCloudLab/frostfs-node
[#60] cmd/neofs-node: Initialize network state on boot
Get current epoch number from morph client and store the value in local state structure. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
dae94aa230
commit
0bdfd18469
1 changed files with 14 additions and 0 deletions
|
@ -10,6 +10,7 @@ import (
|
||||||
netmapService "github.com/nspcc-dev/neofs-node/pkg/services/netmap"
|
netmapService "github.com/nspcc-dev/neofs-node/pkg/services/netmap"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"go.uber.org/atomic"
|
"go.uber.org/atomic"
|
||||||
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
// primary solution of local network state dump.
|
// primary solution of local network state dump.
|
||||||
|
@ -58,6 +59,8 @@ func initNetmapService(c *cfg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func bootstrapNode(c *cfg) {
|
func bootstrapNode(c *cfg) {
|
||||||
|
initState(c)
|
||||||
|
|
||||||
err := c.cfgNetmap.wrapper.AddPeer(c.cfgNodeInfo.info)
|
err := c.cfgNetmap.wrapper.AddPeer(c.cfgNodeInfo.info)
|
||||||
fatalOnErr(errors.Wrap(err, "bootstrap error"))
|
fatalOnErr(errors.Wrap(err, "bootstrap error"))
|
||||||
}
|
}
|
||||||
|
@ -82,6 +85,17 @@ func setNetmapNotificationParser(c *cfg, sTyp string, p event.Parser) {
|
||||||
c.cfgNetmap.parsers[typ] = p
|
c.cfgNetmap.parsers[typ] = p
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func initState(c *cfg) {
|
||||||
|
epoch, err := c.cfgNetmap.wrapper.Epoch()
|
||||||
|
fatalOnErr(errors.Wrap(err, "could not initialize current epoch number"))
|
||||||
|
|
||||||
|
c.log.Info("initial epoch number",
|
||||||
|
zap.Uint64("value", epoch),
|
||||||
|
)
|
||||||
|
|
||||||
|
c.cfgNetmap.state.setCurrentEpoch(epoch)
|
||||||
|
}
|
||||||
|
|
||||||
func addNewEpochNotificationHandler(c *cfg, h event.Handler) {
|
func addNewEpochNotificationHandler(c *cfg, h event.Handler) {
|
||||||
addNetmapNotificationHandler(c, newEpochNotification, h)
|
addNetmapNotificationHandler(c, newEpochNotification, h)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue