Skip to content

Commit

Permalink
blockchain: check total difficulty only when having same justified bl…
Browse files Browse the repository at this point in the history
…ock number (axieinfinity#321)

In fork choice, we only need to compare the difficulty of forks when the
justified block numbers are the same in those forks. Otherwise, we choose the
fork with higher justified block number. This commit fixes a bug in current fork
choice to make it follow the correct behavior.
  • Loading branch information
minh-bq committed Aug 29, 2023
1 parent 2792204 commit fbf7439
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -1331,6 +1331,8 @@ func (bc *BlockChain) reorgNeeded(localBlock *types.Block, localTd *big.Int, ext

if externJustifiedBlockNumber > localJustifiedBlockNumber {
return true
} else if externJustifiedBlockNumber < localJustifiedBlockNumber {
return false
}
}

Expand Down

0 comments on commit fbf7439

Please sign in to comment.