mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-08 07:58:40 +00:00
minor improvements
This commit is contained in:
parent
bfd03b86ae
commit
91b40ed46f
2 changed files with 8 additions and 5 deletions
|
|
@ -720,10 +720,12 @@ func (bc *BlockChain) loadLastState() error {
|
|||
|
||||
// initializeHistoryPruning sets bc.historyPrunePoint based on actual DB state.
|
||||
func (bc *BlockChain) initializeHistoryPruning(latest uint64) error {
|
||||
freezerTail, _ := bc.db.Tail()
|
||||
policy := bc.cfg.HistoryPolicy
|
||||
var (
|
||||
freezerTail, _ = bc.db.Tail()
|
||||
policy = bc.cfg.HistoryPolicy
|
||||
target uint64
|
||||
)
|
||||
// Compute the current prune target from the policy.
|
||||
var target uint64
|
||||
switch policy.Mode {
|
||||
case history.KeepAll:
|
||||
if freezerTail > 0 {
|
||||
|
|
@ -739,8 +741,9 @@ func (bc *BlockChain) initializeHistoryPruning(latest uint64) error {
|
|||
case history.KeepRecent:
|
||||
head := bc.CurrentBlock()
|
||||
if head == nil || head.Number.Uint64() <= policy.Window {
|
||||
// Chain too short for pruning. Record actual DB state.
|
||||
if freezerTail > 0 {
|
||||
// Chain too short for pruning. Record actual DB state.
|
||||
log.Warn("Chain too short for pruning", "tail", freezerTail, "window", policy.Window)
|
||||
bc.updateHistoryPrunePoint(freezerTail)
|
||||
}
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -473,7 +473,7 @@ func (bc *BlockChain) StateIndexProgress() (uint64, error) {
|
|||
return bc.triedb.IndexProgress()
|
||||
}
|
||||
|
||||
// HistoryPruningCutoff returns the actual history pruning point based on DB state.
|
||||
// HistoryPruningCutoff returns the history pruning point based on DB state.
|
||||
// Blocks before this are not available in the database.
|
||||
func (bc *BlockChain) HistoryPruningCutoff() (uint64, common.Hash) {
|
||||
pt := bc.historyPrunePoint.Load()
|
||||
|
|
|
|||
Loading…
Reference in a new issue