[#83] cmd/neofs-node: Add network state option to response service

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-10-22 14:24:08 +03:00 committed by Alex Vanin
parent 7fdb14cf8a
commit d05b2ff500
2 changed files with 6 additions and 2 deletions

View file

@ -228,6 +228,8 @@ func initCfg(path string) *cfg {
maxChunkSize := viperCfg.GetUint64(cfgMaxMsgSize) * 3 / 4 // 25% to meta, 75% to payload maxChunkSize := viperCfg.GetUint64(cfgMaxMsgSize) * 3 / 4 // 25% to meta, 75% to payload
maxAddrAmount := maxChunkSize / addressSize // each address is about 72 bytes maxAddrAmount := maxChunkSize / addressSize // each address is about 72 bytes
state := newNetworkState()
c := &cfg{ c := &cfg{
ctx: context.Background(), ctx: context.Background(),
viper: viperCfg, viper: viperCfg,
@ -246,6 +248,7 @@ func initCfg(path string) *cfg {
cfgNetmap: cfgNetmap{ cfgNetmap: cfgNetmap{
scriptHash: u160Netmap, scriptHash: u160Netmap,
fee: util.Fixed8(viperCfg.GetInt(cfgNetmapFee)), fee: util.Fixed8(viperCfg.GetInt(cfgNetmapFee)),
state: state,
}, },
cfgNodeInfo: cfgNodeInfo{ cfgNodeInfo: cfgNodeInfo{
bootType: StorageNode, bootType: StorageNode,
@ -260,7 +263,9 @@ func initCfg(path string) *cfg {
enableReflectService: viperCfg.GetBool(cfgReflectService), enableReflectService: viperCfg.GetBool(cfgReflectService),
}, },
localAddr: netAddr, localAddr: netAddr,
respSvc: response.NewService(), respSvc: response.NewService(
response.WithNetworkState(state),
),
} }
initLocalStorage(c) initLocalStorage(c)

View file

@ -55,7 +55,6 @@ func initNetmapService(c *cfg) {
), ),
) )
c.cfgNetmap.state = newNetworkState()
addNewEpochNotificationHandler(c, func(ev event.Event) { addNewEpochNotificationHandler(c, func(ev event.Event) {
c.cfgNetmap.state.setCurrentEpoch(ev.(netmapEvent.NewEpoch).EpochNumber()) c.cfgNetmap.state.setCurrentEpoch(ev.(netmapEvent.NewEpoch).EpochNumber())
}) })