mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-24 12:37:16 +00:00
Prine tries (in memory) in the same cycle as db commits, commit before closing db
This commit is contained in:
parent
103deffd86
commit
540eb04273
@ -133,6 +133,7 @@ func stateless(chaindata string, statefile string, triesize int) {
|
|||||||
check(err)
|
check(err)
|
||||||
stateDb, err := ethdb.NewBoltDatabase(statefile)
|
stateDb, err := ethdb.NewBoltDatabase(statefile)
|
||||||
check(err)
|
check(err)
|
||||||
|
defer stateDb.Close()
|
||||||
db := stateDb.DB()
|
db := stateDb.DB()
|
||||||
blockNum := uint64(*block)
|
blockNum := uint64(*block)
|
||||||
var preRoot common.Hash
|
var preRoot common.Hash
|
||||||
@ -275,6 +276,7 @@ func stateless(chaindata string, statefile string, triesize int) {
|
|||||||
fmt.Printf("Failed to commit batch: %v\n", err)
|
fmt.Printf("Failed to commit batch: %v\n", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
tds.PruneTries(false)
|
||||||
}
|
}
|
||||||
if (blockNum > 2000000 && blockNum%500000 == 0) || (blockNum > 4000000 && blockNum%100000 == 0) {
|
if (blockNum > 2000000 && blockNum%500000 == 0) || (blockNum > 4000000 && blockNum%100000 == 0) {
|
||||||
// Snapshots of the state will be written to the same directory as the state file
|
// Snapshots of the state will be written to the same directory as the state file
|
||||||
@ -283,7 +285,6 @@ func stateless(chaindata string, statefile string, triesize int) {
|
|||||||
preRoot = header.Root
|
preRoot = header.Root
|
||||||
blockNum++
|
blockNum++
|
||||||
if blockNum%1000 == 0 {
|
if blockNum%1000 == 0 {
|
||||||
tds.PruneTries(false)
|
|
||||||
fmt.Printf("Processed %d blocks\n", blockNum)
|
fmt.Printf("Processed %d blocks\n", blockNum)
|
||||||
}
|
}
|
||||||
// Check for interrupts
|
// Check for interrupts
|
||||||
@ -293,7 +294,6 @@ func stateless(chaindata string, statefile string, triesize int) {
|
|||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stateDb.Close()
|
|
||||||
fmt.Printf("Processed %d blocks\n", blockNum)
|
fmt.Printf("Processed %d blocks\n", blockNum)
|
||||||
fmt.Printf("Next time specify -block %d\n", blockNum)
|
fmt.Printf("Next time specify -block %d\n", blockNum)
|
||||||
fmt.Printf("Stateless client analysis took %s\n", time.Since(startTime))
|
fmt.Printf("Stateless client analysis took %s\n", time.Since(startTime))
|
||||||
|
Loading…
Reference in New Issue
Block a user