aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgary rong <garyrong0905@gmail.com>2019-05-27 17:05:45 +0800
committerPéter Szilágyi <peterke@gmail.com>2019-05-27 17:05:45 +0800
commit611113e9678b8118e5ec624d9e9f0999f1d4a081 (patch)
treef993b283458137f106d328a1816677225ff9779c
parent4e0c1a1a6b97ad062d79c7c8717273cc51f0111c (diff)
downloadgo-tangerine-611113e9678b8118e5ec624d9e9f0999f1d4a081.tar
go-tangerine-611113e9678b8118e5ec624d9e9f0999f1d4a081.tar.gz
go-tangerine-611113e9678b8118e5ec624d9e9f0999f1d4a081.tar.bz2
go-tangerine-611113e9678b8118e5ec624d9e9f0999f1d4a081.tar.lz
go-tangerine-611113e9678b8118e5ec624d9e9f0999f1d4a081.tar.xz
go-tangerine-611113e9678b8118e5ec624d9e9f0999f1d4a081.tar.zst
go-tangerine-611113e9678b8118e5ec624d9e9f0999f1d4a081.zip
core: never delete genesis block (#19617)
-rw-r--r--core/blockchain.go14
1 files changed, 10 insertions, 4 deletions
diff --git a/core/blockchain.go b/core/blockchain.go
index 7ab6806c2..60707281c 100644
--- a/core/blockchain.go
+++ b/core/blockchain.go
@@ -1076,8 +1076,11 @@ func (bc *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain [
// Wipe out canonical block data.
for _, block := range append(deleted, blockChain...) {
- rawdb.DeleteBlockWithoutNumber(batch, block.Hash(), block.NumberU64())
- rawdb.DeleteCanonicalHash(batch, block.NumberU64())
+ // Always keep genesis block in active database.
+ if block.NumberU64() != 0 {
+ rawdb.DeleteBlockWithoutNumber(batch, block.Hash(), block.NumberU64())
+ rawdb.DeleteCanonicalHash(batch, block.NumberU64())
+ }
}
if err := batch.Write(); err != nil {
return 0, err
@@ -1086,8 +1089,11 @@ func (bc *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain [
// Wipe out side chain too.
for _, block := range append(deleted, blockChain...) {
- for _, hash := range rawdb.ReadAllHashes(bc.db, block.NumberU64()) {
- rawdb.DeleteBlock(batch, hash, block.NumberU64())
+ // Always keep genesis block in active database.
+ if block.NumberU64() != 0 {
+ for _, hash := range rawdb.ReadAllHashes(bc.db, block.NumberU64()) {
+ rawdb.DeleteBlock(batch, hash, block.NumberU64())
+ }
}
}
if err := batch.Write(); err != nil {