[#404] innerring: Make notary deposit periodically

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2021-02-24 18:46:01 +03:00 committed by Alex Vanin
parent ccaf4f5d55
commit 71dce97b76
3 changed files with 56 additions and 0 deletions

View file

@ -42,6 +42,14 @@ type (
emitDuration uint32 // in blocks
}
notaryDepositArgs struct {
l *zap.Logger
depositor func() error
notaryDuration uint32 // in blocks
}
)
func (s *Server) addBlockTimer(t *timers.BlockTimer) {
@ -130,3 +138,16 @@ func newEmissionTimer(args *emitTimerArgs) *timers.BlockTimer {
},
)
}
func newNotaryDepositTimer(args *notaryDepositArgs) *timers.BlockTimer {
return timers.NewBlockTimer(
timers.StaticBlockMeter(args.notaryDuration),
func() {
err := args.depositor()
if err != nil {
args.l.Warn("can't deposit notary contract",
zap.String("error", err.Error()))
}
},
)
}