forked from TrueCloudLab/frostfs-node
[#478] innerring: Use dynamic epoch duration in epoch timer
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
c33512d976
commit
dc0bd782d2
3 changed files with 19 additions and 5 deletions
|
@ -29,9 +29,9 @@ type (
|
|||
cnrWrapper *container.Wrapper // to invoke stop container estimation
|
||||
epoch epochState // to specify which epoch to stop
|
||||
|
||||
epochDuration uint32 // in blocks
|
||||
stopEstimationDMul uint32 // X: X/Y of epoch in blocks
|
||||
stopEstimationDDiv uint32 // Y: X/Y of epoch in blocks
|
||||
epochDuration timers.BlockMeter // in blocks
|
||||
stopEstimationDMul uint32 // X: X/Y of epoch in blocks
|
||||
stopEstimationDDiv uint32 // Y: X/Y of epoch in blocks
|
||||
|
||||
collectBasicIncome subEpochEventHandler
|
||||
distributeBasicIncome subEpochEventHandler
|
||||
|
@ -74,7 +74,7 @@ func (s *Server) tickTimers() {
|
|||
|
||||
func newEpochTimer(args *epochTimerArgs) *timers.BlockTimer {
|
||||
epochTimer := timers.NewBlockTimer(
|
||||
timers.StaticBlockMeter(args.epochDuration),
|
||||
args.epochDuration,
|
||||
func() {
|
||||
args.nm.HandleNewEpochTick(timers.NewEpochTick{})
|
||||
},
|
||||
|
|
|
@ -46,3 +46,17 @@ func (c *GlobalConfig) AuditFee() (uint64, error) {
|
|||
|
||||
return c.nm.AuditFee()
|
||||
}
|
||||
|
||||
func (c *GlobalConfig) EpochDuration() (uint32, error) {
|
||||
value := c.cfg.GetUint32("timers.epoch")
|
||||
if value != 0 {
|
||||
return value, nil
|
||||
}
|
||||
|
||||
epochDuration, err := c.nm.EpochDuration()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return uint32(epochDuration), nil
|
||||
}
|
||||
|
|
|
@ -585,7 +585,7 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper) (*Server, error
|
|||
nm: netmapProcessor,
|
||||
cnrWrapper: cnrClient,
|
||||
epoch: server,
|
||||
epochDuration: cfg.GetUint32("timers.epoch"),
|
||||
epochDuration: globalConfig.EpochDuration,
|
||||
stopEstimationDMul: cfg.GetUint32("timers.stop_estimation.mul"),
|
||||
stopEstimationDDiv: cfg.GetUint32("timers.stop_estimation.div"),
|
||||
collectBasicIncome: subEpochEventHandler{
|
||||
|
|
Loading…
Reference in a new issue