Commit 611113e9 authored by gary rong's avatar gary rong Committed by Péter Szilágyi

core: never delete genesis block (#19617)

parent 4e0c1a1a
...@@ -1076,9 +1076,12 @@ func (bc *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain [ ...@@ -1076,9 +1076,12 @@ func (bc *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain [
// Wipe out canonical block data. // Wipe out canonical block data.
for _, block := range append(deleted, blockChain...) { for _, block := range append(deleted, blockChain...) {
// Always keep genesis block in active database.
if block.NumberU64() != 0 {
rawdb.DeleteBlockWithoutNumber(batch, block.Hash(), block.NumberU64()) rawdb.DeleteBlockWithoutNumber(batch, block.Hash(), block.NumberU64())
rawdb.DeleteCanonicalHash(batch, block.NumberU64()) rawdb.DeleteCanonicalHash(batch, block.NumberU64())
} }
}
if err := batch.Write(); err != nil { if err := batch.Write(); err != nil {
return 0, err return 0, err
} }
...@@ -1086,10 +1089,13 @@ func (bc *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain [ ...@@ -1086,10 +1089,13 @@ func (bc *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain [
// Wipe out side chain too. // Wipe out side chain too.
for _, block := range append(deleted, blockChain...) { for _, block := range append(deleted, blockChain...) {
// Always keep genesis block in active database.
if block.NumberU64() != 0 {
for _, hash := range rawdb.ReadAllHashes(bc.db, block.NumberU64()) { for _, hash := range rawdb.ReadAllHashes(bc.db, block.NumberU64()) {
rawdb.DeleteBlock(batch, hash, block.NumberU64()) rawdb.DeleteBlock(batch, hash, block.NumberU64())
} }
} }
}
if err := batch.Write(); err != nil { if err := batch.Write(); err != nil {
return 0, err return 0, err
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment