[#873] innerring: Use multihanders in the New epoch timer

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2021-10-11 20:10:45 +03:00 committed by Alex Vanin
parent 4afccab015
commit 6638f7d9e6

View file

@ -777,7 +777,7 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper) (*Server, error
// initialize epoch timers
server.epochTimer = newEpochTimer(&epochTimerArgs{
l: server.log,
nm: server.netmapProcessor,
newEpochHandlers: server.newEpochHandlers(log),
cnrWrapper: cnrClient,
epoch: server,
epochDuration: globalConfig.EpochDuration,
@ -805,25 +805,6 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper) (*Server, error
server.addBlockTimer(emissionTimer)
// initialize notary timers
if !server.mainNotaryConfig.disabled {
mainNotaryTimer := newNotaryDepositTimer(&notaryDepositArgs{
l: log,
depositor: server.depositMainNotary,
})
server.addBlockTimer(mainNotaryTimer)
}
if !server.sideNotaryConfig.disabled {
sideNotaryTimer := newNotaryDepositTimer(&notaryDepositArgs{
l: log,
depositor: server.depositSideNotary,
})
server.addBlockTimer(sideNotaryTimer)
}
controlSvcEndpoint := cfg.GetString("control.grpc.endpoint")
if controlSvcEndpoint != "" {
authKeysStr := cfg.GetStringSlice("control.authorized_keys")
@ -1039,3 +1020,31 @@ func (s *Server) onlyAlphabetEventHandler(f event.Handler) event.Handler {
}
}
}
func (s *Server) newEpochHandlers(log *zap.Logger) []newEpochHandler {
newEpochHandlers := []newEpochHandler{
func() {
s.netmapProcessor.HandleNewEpochTick(timerEvent.NewEpochTick{})
},
}
if !s.mainNotaryConfig.disabled {
newEpochHandlers = append(newEpochHandlers,
newNotaryDepositHandler(&notaryDepositArgs{
l: log,
depositor: s.depositMainNotary,
}),
)
}
if !s.sideNotaryConfig.disabled {
newEpochHandlers = append(newEpochHandlers,
newNotaryDepositHandler(&notaryDepositArgs{
l: log,
depositor: s.depositSideNotary,
}),
)
}
return newEpochHandlers
}