core/rawdb: keep genesis in key-value store for full sync too
This commit is contained in:
parent
611113e967
commit
7392f59e7c
|
@ -335,19 +335,25 @@ func (f *freezer) freeze(db ethdb.KeyValueStore) {
|
||||||
// Wipe out all data from the active database
|
// Wipe out all data from the active database
|
||||||
batch := db.NewBatch()
|
batch := db.NewBatch()
|
||||||
for i := 0; i < len(ancients); i++ {
|
for i := 0; i < len(ancients); i++ {
|
||||||
|
// Always keep the genesis block in active database
|
||||||
|
if first+uint64(i) != 0 {
|
||||||
DeleteBlockWithoutNumber(batch, ancients[i], first+uint64(i))
|
DeleteBlockWithoutNumber(batch, ancients[i], first+uint64(i))
|
||||||
DeleteCanonicalHash(batch, first+uint64(i))
|
DeleteCanonicalHash(batch, first+uint64(i))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if err := batch.Write(); err != nil {
|
if err := batch.Write(); err != nil {
|
||||||
log.Crit("Failed to delete frozen canonical blocks", "err", err)
|
log.Crit("Failed to delete frozen canonical blocks", "err", err)
|
||||||
}
|
}
|
||||||
batch.Reset()
|
batch.Reset()
|
||||||
// Wipe out side chain also.
|
// Wipe out side chain also.
|
||||||
for number := first; number < f.frozen; number++ {
|
for number := first; number < f.frozen; number++ {
|
||||||
|
// Always keep the genesis block in active database
|
||||||
|
if number != 0 {
|
||||||
for _, hash := range ReadAllHashes(db, number) {
|
for _, hash := range ReadAllHashes(db, number) {
|
||||||
DeleteBlock(batch, hash, number)
|
DeleteBlock(batch, hash, number)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if err := batch.Write(); err != nil {
|
if err := batch.Write(); err != nil {
|
||||||
log.Crit("Failed to delete frozen side blocks", "err", err)
|
log.Crit("Failed to delete frozen side blocks", "err", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue