fix/backup-initialization
frozen 9 months ago
parent fa5efdc5dc
commit 98e103cfcb
No known key found for this signature in database
GPG Key ID: 5391C63E79B03EDE
  1. 6
      consensus/consensus.go
  2. 4
      consensus/consensus_service.go
  3. 2
      consensus/consensus_v2.go
  4. 4
      consensus/validator.go
  5. 2
      consensus/view_change.go

@ -53,8 +53,6 @@ type Consensus struct {
phase FBFTPhase
// current indicates what state a node is in
current State
// isBackup declarative the node is in backup mode
isBackup bool
// 2 types of timeouts: normal and viewchange
consensusTimeout map[TimeoutType]*utils.Timeout
// Commits collected from validators.
@ -254,9 +252,7 @@ func (consensus *Consensus) getConsensusLeaderPrivateKey() (*bls.PrivateKeyWrapp
}
func (consensus *Consensus) IsBackup() bool {
consensus.mutex.RLock()
defer consensus.mutex.RUnlock()
return consensus.isBackup
return consensus.registry.IsBackup()
}
func (consensus *Consensus) BlockNum() uint64 {

@ -199,11 +199,11 @@ func (consensus *Consensus) setMode(m Mode) {
// SetIsBackup sets the mode of consensus
func (consensus *Consensus) SetIsBackup(isBackup bool) {
consensus.mutex.Lock()
defer consensus.mutex.Unlock()
consensus.getLogger().Debug().
Bool("IsBackup", isBackup).
Msg("[SetIsBackup]")
consensus.isBackup = isBackup
consensus.mutex.Unlock()
consensus.registry.SetIsBackup(isBackup)
}
// Mode returns the mode of consensus

@ -106,7 +106,7 @@ func (consensus *Consensus) HandleMessageUpdate(ctx context.Context, peer libp2p
consensus.isLeader()
// if in backup normal mode, force ignore view change event and leader event.
if consensus.isBackup {
if consensus.registry.IsBackup() {
canHandleViewChange = false
intendedForLeader = false
}

@ -133,7 +133,7 @@ func (consensus *Consensus) validateNewBlock(recvMsg *FBFTMessage) (*types.Block
}
func (consensus *Consensus) prepare() {
if consensus.isBackup {
if consensus.registry.IsBackup() {
return
}
@ -152,7 +152,7 @@ func (consensus *Consensus) prepare() {
// sendCommitMessages send out commit messages to leader
func (consensus *Consensus) sendCommitMessages(blockObj *types.Block) {
if consensus.isBackup || blockObj == nil {
if consensus.IsBackup() || blockObj == nil {
return
}

@ -231,7 +231,7 @@ func createTimeout() map[TimeoutType]*utils.Timeout {
// startViewChange start the view change process
func (consensus *Consensus) startViewChange() {
if consensus.disableViewChange || consensus.isBackup {
if consensus.disableViewChange || consensus.registry.IsBackup() {
return
}

Loading…
Cancel
Save