Skip to content

Commit

Permalink
initial snapshot when there is no snapshot (ethereum#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
liam-lai authored May 18, 2022
1 parent 5fffa0c commit 2b40d13
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions consensus/XDPoS/engines/engine_v2/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,13 @@ func (x *XDPoS_v2) Initial(chain consensus.ChainReader, header *types.Header) er
}

// Initial first v2 snapshot
if header.Number.Uint64() < x.config.V2.SwitchBlock.Uint64()+x.config.Gap {
lastGapNum := x.config.V2.SwitchBlock.Uint64() - x.config.Gap
lastGapHeader := chain.GetHeaderByNumber(lastGapNum)

checkpointBlockNumber := header.Number.Uint64() - header.Number.Uint64()%x.config.Epoch
checkpointHeader := chain.GetHeaderByNumber(checkpointBlockNumber)
snap, _ := loadSnapshot(x.db, lastGapHeader.Hash())

lastGapNum := checkpointBlockNumber - x.config.Gap
lastGapHeader := chain.GetHeaderByNumber(lastGapNum)
if snap == nil {
checkpointHeader := chain.GetHeaderByNumber(x.config.V2.SwitchBlock.Uint64())

log.Info("[Initial] init first snapshot")
_, _, masternodes, err := x.getExtraFields(checkpointHeader)
Expand Down

0 comments on commit 2b40d13

Please sign in to comment.