[#360] Run basic income collection in inner ring

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2021-02-01 19:20:33 +03:00 committed by Alex Vanin
parent 8c4bf81351
commit be2ed6bf4c
4 changed files with 98 additions and 8 deletions

View file

@ -3,8 +3,10 @@ package innerring
import (
"github.com/nspcc-dev/neofs-node/pkg/innerring/processors/alphabet"
"github.com/nspcc-dev/neofs-node/pkg/innerring/processors/netmap"
"github.com/nspcc-dev/neofs-node/pkg/innerring/processors/settlement"
"github.com/nspcc-dev/neofs-node/pkg/innerring/timers"
container "github.com/nspcc-dev/neofs-node/pkg/morph/client/container/wrapper"
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
"go.uber.org/zap"
)
@ -24,6 +26,10 @@ type (
epochDuration uint32 // in blocks
stopEstimationDMul uint32 // X: X/Y of epoch in blocks
stopEstimationDDiv uint32 // Y: X/Y of epoch in blocks
collectBasicIncome event.Handler // handle collect basic income
collectBasicIncomeDMul uint32 // X: X/Y of epoch in blocks
collectBasicIncomeDDiv uint32 // Y: X/Y of epoch in blocks
}
emitTimerArgs struct {
@ -80,6 +86,18 @@ func newEpochTimer(args *epochTimerArgs) *timers.BlockTimer {
}
})
epochTimer.OnDelta(
args.collectBasicIncomeDMul,
args.collectBasicIncomeDDiv,
func() {
epochN := args.epoch.EpochCounter()
if epochN == 0 { // estimates are invalid in genesis epoch
return
}
args.collectBasicIncome(settlement.NewBasicIncomeCollectEvent(epochN - 1))
})
return epochTimer
}