mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
update based on freeezr
This commit is contained in:
parent
e933ed48a8
commit
6f8293d272
2 changed files with 9 additions and 18 deletions
|
|
@ -665,7 +665,7 @@ func pruneHistory(ctx *cli.Context) error {
|
||||||
// TODO(s1na): what if there is a crash between the two prune operations?
|
// TODO(s1na): what if there is a crash between the two prune operations?
|
||||||
|
|
||||||
// Truncate everything up to merge block
|
// Truncate everything up to merge block
|
||||||
if _, err := chaindb.TruncateTail(mergeBlock); err != nil {
|
if _, err := chaindb.TruncateTailBlocks(mergeBlock); err != nil {
|
||||||
return fmt.Errorf("failed to truncate ancient data: %v", err)
|
return fmt.Errorf("failed to truncate ancient data: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -222,14 +222,6 @@ func NewDatabaseWithFreezer(db ethdb.KeyValueStore, ancient string, namespace st
|
||||||
// it to the freezer content.
|
// it to the freezer content.
|
||||||
if kvgenesis, _ := db.Get(headerHashKey(0)); len(kvgenesis) > 0 {
|
if kvgenesis, _ := db.Get(headerHashKey(0)); len(kvgenesis) > 0 {
|
||||||
if frozen, _ := frdb.Ancients(); frozen > 0 {
|
if frozen, _ := frdb.Ancients(); frozen > 0 {
|
||||||
tail, err := frdb.Tail()
|
|
||||||
if err != nil {
|
|
||||||
printChainMetadata(db)
|
|
||||||
return nil, fmt.Errorf("failed to retrieve tail from freezer %v", err)
|
|
||||||
}
|
|
||||||
// If tail > 0, the history has been pruned and genesis block is not anymore in the freezer.
|
|
||||||
// TODO: we need another way to verify the network for kvdb and freezer match.
|
|
||||||
if tail == 0 {
|
|
||||||
// If the freezer already contains something, ensure that the genesis blocks
|
// If the freezer already contains something, ensure that the genesis blocks
|
||||||
// match, otherwise we might mix up freezers across chains and destroy both
|
// match, otherwise we might mix up freezers across chains and destroy both
|
||||||
// the freezer and the key-value store.
|
// the freezer and the key-value store.
|
||||||
|
|
@ -241,7 +233,6 @@ func NewDatabaseWithFreezer(db ethdb.KeyValueStore, ancient string, namespace st
|
||||||
printChainMetadata(db)
|
printChainMetadata(db)
|
||||||
return nil, fmt.Errorf("genesis mismatch: %#x (leveldb) != %#x (ancients)", kvgenesis, frgenesis)
|
return nil, fmt.Errorf("genesis mismatch: %#x (leveldb) != %#x (ancients)", kvgenesis, frgenesis)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// Key-value store and freezer belong to the same network. Ensure that they
|
// Key-value store and freezer belong to the same network. Ensure that they
|
||||||
// are contiguous, otherwise we might end up with a non-functional freezer.
|
// are contiguous, otherwise we might end up with a non-functional freezer.
|
||||||
if kvhash, _ := db.Get(headerHashKey(frozen)); len(kvhash) == 0 {
|
if kvhash, _ := db.Get(headerHashKey(frozen)); len(kvhash) == 0 {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue