forked from TrueCloudLab/frostfs-node
[#134] Resend bootstrap txs periodically
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
c7975dbe87
commit
2bd827a478
2 changed files with 27 additions and 3 deletions
|
@ -86,6 +86,9 @@ const (
|
||||||
cfgPolicerHeadTimeout = "policer.head_timeout"
|
cfgPolicerHeadTimeout = "policer.head_timeout"
|
||||||
|
|
||||||
cfgReplicatorPutTimeout = "replicator.put_timeout"
|
cfgReplicatorPutTimeout = "replicator.put_timeout"
|
||||||
|
|
||||||
|
cfgReBootstrapEnabled = "bootstrap.periodic.enabled"
|
||||||
|
cfgReBootstrapInterval = "bootstrap.periodic.interval"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -169,6 +172,9 @@ type cfgNetmap struct {
|
||||||
subscribers map[event.Type][]event.Handler
|
subscribers map[event.Type][]event.Handler
|
||||||
|
|
||||||
state *networkState
|
state *networkState
|
||||||
|
|
||||||
|
reBootstrapEnabled bool
|
||||||
|
reBootstrapInterval uint64 // in epochs
|
||||||
}
|
}
|
||||||
|
|
||||||
type BootstrapType uint32
|
type BootstrapType uint32
|
||||||
|
@ -248,6 +254,8 @@ func initCfg(path string) *cfg {
|
||||||
scriptHash: u160Netmap,
|
scriptHash: u160Netmap,
|
||||||
fee: util.Fixed8(viperCfg.GetInt(cfgNetmapFee)),
|
fee: util.Fixed8(viperCfg.GetInt(cfgNetmapFee)),
|
||||||
state: state,
|
state: state,
|
||||||
|
reBootstrapInterval: viperCfg.GetUint64(cfgReBootstrapInterval),
|
||||||
|
reBootstrapEnabled: viperCfg.GetBool(cfgReBootstrapEnabled),
|
||||||
},
|
},
|
||||||
cfgNodeInfo: cfgNodeInfo{
|
cfgNodeInfo: cfgNodeInfo{
|
||||||
bootType: StorageNode,
|
bootType: StorageNode,
|
||||||
|
@ -332,6 +340,9 @@ func defaultConfiguration(v *viper.Viper) {
|
||||||
v.SetDefault(cfgPolicerHeadTimeout, 5*time.Second)
|
v.SetDefault(cfgPolicerHeadTimeout, 5*time.Second)
|
||||||
|
|
||||||
v.SetDefault(cfgReplicatorPutTimeout, 5*time.Second)
|
v.SetDefault(cfgReplicatorPutTimeout, 5*time.Second)
|
||||||
|
|
||||||
|
v.SetDefault(cfgReBootstrapEnabled, false) // in epochs
|
||||||
|
v.SetDefault(cfgReBootstrapInterval, 2) // in epochs
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *cfg) LocalAddress() *network.Address {
|
func (c *cfg) LocalAddress() *network.Address {
|
||||||
|
|
|
@ -58,6 +58,19 @@ func initNetmapService(c *cfg) {
|
||||||
addNewEpochNotificationHandler(c, func(ev event.Event) {
|
addNewEpochNotificationHandler(c, func(ev event.Event) {
|
||||||
c.cfgNetmap.state.setCurrentEpoch(ev.(netmapEvent.NewEpoch).EpochNumber())
|
c.cfgNetmap.state.setCurrentEpoch(ev.(netmapEvent.NewEpoch).EpochNumber())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if c.cfgNetmap.reBootstrapEnabled {
|
||||||
|
addNewEpochNotificationHandler(c, func(ev event.Event) {
|
||||||
|
n := ev.(netmapEvent.NewEpoch).EpochNumber()
|
||||||
|
|
||||||
|
if n%c.cfgNetmap.reBootstrapInterval == 0 {
|
||||||
|
err := c.cfgNetmap.wrapper.AddPeer(c.cfgNodeInfo.info)
|
||||||
|
if err != nil {
|
||||||
|
c.log.Warn("can't send re-bootstrap tx", zap.Error(err))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func bootstrapNode(c *cfg) {
|
func bootstrapNode(c *cfg) {
|
||||||
|
|
Loading…
Reference in a new issue