Skip to content

Commit

Permalink
chore: change check for rewind
Browse files Browse the repository at this point in the history
  • Loading branch information
joeylichang committed Sep 4, 2024
1 parent 3e7f56f commit de4be08
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -785,13 +785,15 @@ func (bc *BlockChain) loadLastState() error {
log.Info("begin rewind versa db head", "target_number", archiveVersion, "target_root", archiveRoot.String())
for {
log.Info("rewinding block", "number", headBlock.NumberU64(), "hash", headBlock.Hash(), "root", headBlock.Root().String(), "target_number", archiveVersion, "target_root", archiveRoot.String())
if archiveRoot.Cmp(headBlock.Root()) == 0 {
if archiveRoot.Cmp(headBlock.Root()) == 0 && archiveVersion == headBlock.Number().Int64() {
rawdb.WriteCanonicalHash(bc.db, headBlock.Hash(), headBlock.NumberU64())
rawdb.WriteHeadHeaderHash(bc.db, headBlock.Hash())
rawdb.WriteHeadBlockHash(bc.db, headBlock.Hash())
rawdb.WriteHeadFastBlockHash(bc.db, headBlock.Hash())
log.Info("success to reset versa db head block", "number", headBlock.NumberU64(), "hash", headBlock.Hash(), "root", headBlock.Root().String())
break
} else if archiveRoot.Cmp(headBlock.Root()) == 0 {
log.Info("reset versa db meet same root", "number", headBlock.NumberU64(), "target_number", archiveVersion, "target_root", archiveRoot.String())
} else if archiveVersion == headBlock.Number().Int64() {
log.Crit("failed to reset versa db meet same version", "number", headBlock.NumberU64(), "target_number", archiveVersion, "target_root", archiveRoot.String())
}
Expand Down

0 comments on commit de4be08

Please sign in to comment.