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,7 +29,7 @@ type (
|
||||||
cnrWrapper *container.Wrapper // to invoke stop container estimation
|
cnrWrapper *container.Wrapper // to invoke stop container estimation
|
||||||
epoch epochState // to specify which epoch to stop
|
epoch epochState // to specify which epoch to stop
|
||||||
|
|
||||||
epochDuration uint32 // in blocks
|
epochDuration timers.BlockMeter // in blocks
|
||||||
stopEstimationDMul uint32 // X: X/Y of epoch in blocks
|
stopEstimationDMul uint32 // X: X/Y of epoch in blocks
|
||||||
stopEstimationDDiv uint32 // Y: X/Y of epoch in blocks
|
stopEstimationDDiv uint32 // Y: X/Y of epoch in blocks
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ func (s *Server) tickTimers() {
|
||||||
|
|
||||||
func newEpochTimer(args *epochTimerArgs) *timers.BlockTimer {
|
func newEpochTimer(args *epochTimerArgs) *timers.BlockTimer {
|
||||||
epochTimer := timers.NewBlockTimer(
|
epochTimer := timers.NewBlockTimer(
|
||||||
timers.StaticBlockMeter(args.epochDuration),
|
args.epochDuration,
|
||||||
func() {
|
func() {
|
||||||
args.nm.HandleNewEpochTick(timers.NewEpochTick{})
|
args.nm.HandleNewEpochTick(timers.NewEpochTick{})
|
||||||
},
|
},
|
||||||
|
|
|
@ -46,3 +46,17 @@ func (c *GlobalConfig) AuditFee() (uint64, error) {
|
||||||
|
|
||||||
return c.nm.AuditFee()
|
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,
|
nm: netmapProcessor,
|
||||||
cnrWrapper: cnrClient,
|
cnrWrapper: cnrClient,
|
||||||
epoch: server,
|
epoch: server,
|
||||||
epochDuration: cfg.GetUint32("timers.epoch"),
|
epochDuration: globalConfig.EpochDuration,
|
||||||
stopEstimationDMul: cfg.GetUint32("timers.stop_estimation.mul"),
|
stopEstimationDMul: cfg.GetUint32("timers.stop_estimation.mul"),
|
||||||
stopEstimationDDiv: cfg.GetUint32("timers.stop_estimation.div"),
|
stopEstimationDDiv: cfg.GetUint32("timers.stop_estimation.div"),
|
||||||
collectBasicIncome: subEpochEventHandler{
|
collectBasicIncome: subEpochEventHandler{
|
||||||
|
|
Loading…
Reference in a new issue