Skip to content

Commit

Permalink
consensus/parlia: defaultEpochLength to p.config.Epoch
Browse files Browse the repository at this point in the history
  • Loading branch information
buddh0 committed Aug 5, 2024
1 parent a8c8207 commit d00ff5d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions consensus/parlia/parlia.go
Original file line number Diff line number Diff line change
Expand Up @@ -742,8 +742,8 @@ func (p *Parlia) snapshot(chain consensus.ChainHeaderReader, number uint64, hash
// If we're at the genesis, snapshot the initial state. Alternatively if we have
// piled up more headers than allowed to be reorged (chain reinit from a freezer),
// consider the checkpoint trusted and snapshot it.
// even BEP-341 enabled, an offset `defaultEpochLength/2` can ensure getting the right validators.
if number == 0 || (number%p.config.Epoch == defaultEpochLength/2 && (len(headers) > int(params.FullImmutabilityThreshold))) {
// even BEP-341 enabled, an offset `p.config.Epoch/2` can ensure getting the right validators.
if number == 0 || (number%p.config.Epoch == p.config.Epoch/2 && (len(headers) > int(params.FullImmutabilityThreshold))) {
var (
checkpoint *types.Header
blockHash common.Hash
Expand All @@ -754,7 +754,7 @@ func (p *Parlia) snapshot(chain consensus.ChainHeaderReader, number uint64, hash
blockHash = checkpoint.Hash()
}
} else {
checkpoint = chain.GetHeaderByNumber(number - defaultEpochLength/2)
checkpoint = chain.GetHeaderByNumber(number - p.config.Epoch/2)
blockHeader := chain.GetHeaderByNumber(number)
if blockHeader != nil {
blockHash = blockHeader.Hash()
Expand Down

0 comments on commit d00ff5d

Please sign in to comment.