2020-07-24 13:54:03 +00:00
|
|
|
package netmap
|
|
|
|
|
|
|
|
import (
|
2020-12-18 09:27:19 +00:00
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/innerring/processors/audit"
|
2021-03-25 13:24:44 +00:00
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/innerring/processors/governance"
|
2021-01-28 19:51:41 +00:00
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/innerring/processors/settlement"
|
2020-07-24 13:54:03 +00:00
|
|
|
"go.uber.org/zap"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Process new epoch notification by setting global epoch value and resetting
|
|
|
|
// local epoch timer.
|
|
|
|
func (np *Processor) processNewEpoch(epoch uint64) {
|
|
|
|
np.epochState.SetEpochCounter(epoch)
|
2021-01-22 15:01:44 +00:00
|
|
|
if err := np.epochTimer.ResetEpochTimer(); err != nil {
|
|
|
|
np.log.Warn("can't reset epoch timer",
|
|
|
|
zap.String("error", err.Error()))
|
|
|
|
}
|
2020-10-29 16:08:36 +00:00
|
|
|
|
|
|
|
// get new netmap snapshot
|
2021-05-31 11:50:11 +00:00
|
|
|
networkMap, err := np.netmapClient.Snapshot()
|
2020-10-29 16:08:36 +00:00
|
|
|
if err != nil {
|
|
|
|
np.log.Warn("can't get netmap snapshot to perform cleanup",
|
|
|
|
zap.String("error", err.Error()))
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-01-29 07:48:47 +00:00
|
|
|
if epoch > 0 { // estimates are invalid in genesis epoch
|
2021-06-02 16:24:30 +00:00
|
|
|
err = np.containerWrp.StartEstimation(epoch - 1)
|
2021-04-29 13:40:34 +00:00
|
|
|
|
2021-01-29 07:48:47 +00:00
|
|
|
if err != nil {
|
|
|
|
np.log.Warn("can't start container size estimation",
|
|
|
|
zap.Uint64("epoch", epoch),
|
|
|
|
zap.String("error", err.Error()))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-21 07:45:15 +00:00
|
|
|
np.netmapSnapshot.update(networkMap, epoch)
|
2020-10-29 16:08:36 +00:00
|
|
|
np.handleCleanupTick(netmapCleanupTick{epoch: epoch})
|
2020-12-18 09:27:19 +00:00
|
|
|
np.handleNewAudit(audit.NewAuditStartEvent(epoch))
|
2021-01-28 19:51:41 +00:00
|
|
|
np.handleAuditSettlements(settlement.NewAuditEvent(epoch))
|
2021-03-25 13:24:44 +00:00
|
|
|
np.handleAlphabetSync(governance.NewSyncEvent())
|
2020-07-24 13:54:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Process new epoch tick by invoking new epoch method in network map contract.
|
|
|
|
func (np *Processor) processNewEpochTick() {
|
2021-03-23 15:20:44 +00:00
|
|
|
if !np.alphabetState.IsAlphabet() {
|
|
|
|
np.log.Info("non alphabet mode, ignore new epoch tick")
|
2020-07-24 13:54:03 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
nextEpoch := np.epochState.EpochCounter() + 1
|
|
|
|
np.log.Debug("next epoch", zap.Uint64("value", nextEpoch))
|
|
|
|
|
2021-05-31 11:50:11 +00:00
|
|
|
err := np.netmapClient.NewEpoch(nextEpoch)
|
2020-07-24 13:54:03 +00:00
|
|
|
if err != nil {
|
|
|
|
np.log.Error("can't invoke netmap.NewEpoch", zap.Error(err))
|
|
|
|
}
|
|
|
|
}
|