Skip to content

Commit

Permalink
Additional isBackup checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
Frozen committed Apr 4, 2024
1 parent 794271d commit a6676fa
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion consensus/consensus_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ func (consensus *Consensus) HandleMessageUpdate(ctx context.Context, peer libp2p

// if in backup normal mode, force ignore view change event and leader event.
if consensus.registry.IsBackup() {
consensus.getLogger().Info().Msgf("IsBackup: true")
canHandleViewChange = false
intendedForLeader = false
}
Expand Down Expand Up @@ -424,7 +425,7 @@ func (consensus *Consensus) BlockChannel(newBlock *types.Block) {
Msg("[ConsensusMainLoop] Received Proposed New Block!")

if newBlock.NumberU64() < consensus.BlockNum() {
consensus.getLogger().Warn().Uint64("newBlockNum", newBlock.NumberU64()).
consensus.GetLogger().Warn().Uint64("newBlockNum", newBlock.NumberU64()).
Msg("[ConsensusMainLoop] received old block, abort")
return
}
Expand Down
4 changes: 4 additions & 0 deletions consensus/leader.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ import (

// announce fires leader
func (consensus *Consensus) announce(block *types.Block) {
if consensus.registry.IsBackup() {
consensus.getLogger().Warn().Msg("[Announce] I am a backup node")
return
}
blockHash := block.Hash()

// prepare message and broadcast to validators
Expand Down
3 changes: 3 additions & 0 deletions consensus/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ import (
)

func (consensus *Consensus) onAnnounce(msg *msg_pb.Message) {
if consensus.registry.IsBackup() {
return
}
recvMsg, err := consensus.parseFBFTMessage(msg)
if err != nil {
consensus.getLogger().Error().
Expand Down

0 comments on commit a6676fa

Please sign in to comment.