[#493] node: Abolish re-bootstrap configurations

From now non-relay node always sends re-bootstrap transaction every 2 epochs
starting from the boot-up epoch.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-05-12 12:27:12 +03:00 committed by Leonard Lyubich
parent 7a64a70b12
commit f90fc86ec8
2 changed files with 17 additions and 22 deletions

View file

@ -96,9 +96,7 @@ const (
cfgReplicatorPutTimeout = "replicator.put_timeout"
cfgReBootstrapRelay = "bootstrap.relay_only"
cfgReBootstrapEnabled = "bootstrap.periodic.enabled"
cfgReBootstrapInterval = "bootstrap.periodic.interval"
cfgReBootstrapRelay = "bootstrap.relay_only"
cfgObjectPutPoolSize = "pool.object.put.size"
cfgObjectGetPoolSize = "pool.object.get.size"
@ -250,7 +248,7 @@ type cfgNetmap struct {
reBootstrapEnabled bool
reBoostrapTurnedOff *atomic.Bool // managed by control service in runtime
reBootstrapInterval uint64 // in epochs
startEpoch uint64 // epoch number when application is started
}
type BootstrapType uint32
@ -377,8 +375,7 @@ func initCfg(path string) *cfg {
scriptHash: u160Netmap,
state: state,
workerPool: netmapWorkerPool,
reBootstrapInterval: viperCfg.GetUint64(cfgReBootstrapInterval),
reBootstrapEnabled: !relayOnly && viperCfg.GetBool(cfgReBootstrapEnabled),
reBootstrapEnabled: !relayOnly,
reBoostrapTurnedOff: atomic.NewBool(relayOnly),
},
cfgNodeInfo: cfgNodeInfo{
@ -459,9 +456,6 @@ func defaultConfiguration(v *viper.Viper) {
v.SetDefault(cfgReplicatorPutTimeout, 5*time.Second)
v.SetDefault(cfgReBootstrapEnabled, false) // in epochs
v.SetDefault(cfgReBootstrapInterval, 2) // in epochs
v.SetDefault(cfgObjectGetPoolSize, 10)
v.SetDefault(cfgObjectHeadPoolSize, 10)
v.SetDefault(cfgObjectPutPoolSize, 10)

View file

@ -73,22 +73,22 @@ func initNetmapService(c *cfg) {
c.cfgNetmap.state.setCurrentEpoch(ev.(netmapEvent.NewEpoch).EpochNumber())
})
if c.cfgNetmap.reBootstrapEnabled {
addNewEpochAsyncNotificationHandler(c, func(ev event.Event) {
if c.cfgNetmap.reBoostrapTurnedOff.Load() { // fixes #470
return
}
addNewEpochAsyncNotificationHandler(c, func(ev event.Event) {
if c.cfgNetmap.reBoostrapTurnedOff.Load() { // fixes #470
return
}
n := ev.(netmapEvent.NewEpoch).EpochNumber()
n := ev.(netmapEvent.NewEpoch).EpochNumber()
if n%c.cfgNetmap.reBootstrapInterval == 0 {
err := c.cfgNetmap.wrapper.AddPeer(c.toOnlineLocalNodeInfo())
if err != nil {
c.log.Warn("can't send re-bootstrap tx", zap.Error(err))
}
const reBootstrapInterval = 2
if (n-c.cfgNetmap.startEpoch)%reBootstrapInterval == 0 {
err := c.cfgNetmap.wrapper.AddPeer(c.toOnlineLocalNodeInfo())
if err != nil {
c.log.Warn("can't send re-bootstrap tx", zap.Error(err))
}
})
}
}
})
addNewEpochAsyncNotificationHandler(c, func(ev event.Event) {
e := ev.(netmapEvent.NewEpoch).EpochNumber()
@ -149,6 +149,7 @@ func initState(c *cfg) {
)
c.cfgNetmap.state.setCurrentEpoch(epoch)
c.cfgNetmap.startEpoch = epoch
}
func (c *cfg) netmapLocalNodeState(epoch uint64) (*netmapSDK.NodeInfo, error) {