[#1900] node: Refactor bootstrap methods

In previous implementation bootstrapping state was chosen according to
bool flag which was not convenient.

Create separate method to boostrap with "online" and the current state.

Signed-off-by: Leonard Lyubich <ctulhurider@gmail.com>
This commit is contained in:
Leonard Lyubich 2022-10-28 11:02:55 +04:00 committed by fyrchik
parent e8c5f03c30
commit db92e96e40
2 changed files with 31 additions and 22 deletions

View file

@ -179,7 +179,7 @@ func initNetmapService(c *cfg) {
const reBootstrapInterval = 2
if (n-c.cfgNetmap.startEpoch)%reBootstrapInterval == 0 {
err := c.bootstrap(false)
err := c.bootstrap()
if err != nil {
c.log.Warn("can't send re-bootstrap tx", zap.Error(err))
}
@ -241,7 +241,7 @@ func readSubnetCfg(c *cfg) {
// Must be called after initNetmapService.
func bootstrapNode(c *cfg) {
if c.needBootstrap() {
err := c.bootstrap(false)
err := c.bootstrap()
fatalOnErrDetails("bootstrap error", err)
}
}
@ -352,7 +352,7 @@ func (c *cfg) SetNetmapStatus(st control.NetmapStatus) error {
if st == control.NetmapStatus_ONLINE {
c.cfgNetmap.reBoostrapTurnedOff.Store(false)
return c.bootstrap(true)
return bootstrapOnline(c)
}
c.cfgNetmap.reBoostrapTurnedOff.Store(true)