frostfs-node/cmd/frostfs-node/timers.go
Pavel Karpy 923f84722a Move to frostfs-node
Signed-off-by: Pavel Karpy <p.karpy@yadro.com>
2022-12-28 15:04:29 +03:00

43 lines
809 B
Go

package main
import (
"sync"
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-node/reputation/ticker"
)
type eigenTrustTickers struct {
m sync.Mutex
timers map[uint64]*ticker.IterationsTicker
}
func (e *eigenTrustTickers) addEpochTimer(epoch uint64, timer *ticker.IterationsTicker) {
e.m.Lock()
defer e.m.Unlock()
e.timers[epoch] = timer
}
func (e *eigenTrustTickers) tick() {
e.m.Lock()
defer e.m.Unlock()
for epoch, t := range e.timers {
if !t.Tick() {
delete(e.timers, epoch)
}
}
}
func tickBlockTimers(c *cfg) {
c.cfgMorph.eigenTrustTicker.tick()
}
func newEigenTrustIterTimer(c *cfg) {
c.cfgMorph.eigenTrustTicker = &eigenTrustTickers{
// it is expected to have max 2 concurrent epoch
// in normal mode work
timers: make(map[uint64]*ticker.IterationsTicker, 2),
}
}