From 7392f59e7ce15c17a1194ae82cd90de101f0ab40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Mon, 27 May 2019 12:25:24 +0300 Subject: [PATCH] core/rawdb: keep genesis in key-value store for full sync too --- core/rawdb/freezer.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/core/rawdb/freezer.go b/core/rawdb/freezer.go index 33da53787..741ff9adb 100644 --- a/core/rawdb/freezer.go +++ b/core/rawdb/freezer.go @@ -335,8 +335,11 @@ func (f *freezer) freeze(db ethdb.KeyValueStore) { // Wipe out all data from the active database batch := db.NewBatch() for i := 0; i < len(ancients); i++ { - DeleteBlockWithoutNumber(batch, ancients[i], first+uint64(i)) - DeleteCanonicalHash(batch, first+uint64(i)) + // Always keep the genesis block in active database + if first+uint64(i) != 0 { + DeleteBlockWithoutNumber(batch, ancients[i], first+uint64(i)) + DeleteCanonicalHash(batch, first+uint64(i)) + } } if err := batch.Write(); err != nil { log.Crit("Failed to delete frozen canonical blocks", "err", err) @@ -344,8 +347,11 @@ func (f *freezer) freeze(db ethdb.KeyValueStore) { batch.Reset() // Wipe out side chain also. for number := first; number < f.frozen; number++ { - for _, hash := range ReadAllHashes(db, number) { - DeleteBlock(batch, hash, number) + // Always keep the genesis block in active database + if number != 0 { + for _, hash := range ReadAllHashes(db, number) { + DeleteBlock(batch, hash, number) + } } } if err := batch.Write(); err != nil {