mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-23 13:16:42 +00:00
triedb/pathdb: improve state history indexing completion log
This commit is contained in:
parent
fc8c8c1314
commit
907ad70623
1 changed files with 43 additions and 2 deletions
|
|
@ -383,6 +383,47 @@ func (i *indexIniter) remain() uint64 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// getHistoryRangeInfo returns a formatted string describing the available history range.
|
||||||
|
func (i *indexIniter) getHistoryRangeInfo(lastID uint64) []interface{} {
|
||||||
|
// Get the number of available history ID
|
||||||
|
tail, err := i.freezer.Tail()
|
||||||
|
if err != nil {
|
||||||
|
return []interface{}{"last", lastID, "error", err}
|
||||||
|
}
|
||||||
|
head, err := i.freezer.Ancients()
|
||||||
|
if err != nil {
|
||||||
|
return []interface{}{"last", lastID, "error", err}
|
||||||
|
}
|
||||||
|
|
||||||
|
firstID := tail + 1
|
||||||
|
lastAvailID := head - 1
|
||||||
|
count := uint64(0)
|
||||||
|
if lastAvailID >= firstID {
|
||||||
|
count = lastAvailID - firstID + 1
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the actual block numbers
|
||||||
|
if count == 0 {
|
||||||
|
return []interface{}{"last", lastID, "count", 0}
|
||||||
|
}
|
||||||
|
|
||||||
|
firstBlock, lastBlock := uint64(0), uint64(0)
|
||||||
|
if i.typ == typeStateHistory {
|
||||||
|
if fh, err := readStateHistory(i.freezer, firstID); err == nil {
|
||||||
|
firstBlock = fh.meta.block
|
||||||
|
}
|
||||||
|
if lh, err := readStateHistory(i.freezer, lastID); err == nil {
|
||||||
|
lastBlock = lh.meta.block
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return []interface{}{
|
||||||
|
"last", lastID,
|
||||||
|
"count", count,
|
||||||
|
"blocks", fmt.Sprintf("%d-%d", firstBlock, lastBlock),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (i *indexIniter) run(lastID uint64) {
|
func (i *indexIniter) run(lastID uint64) {
|
||||||
defer i.wg.Done()
|
defer i.wg.Done()
|
||||||
|
|
||||||
|
|
@ -434,7 +475,7 @@ func (i *indexIniter) run(lastID uint64) {
|
||||||
}
|
}
|
||||||
close(i.done)
|
close(i.done)
|
||||||
signal.result <- nil
|
signal.result <- nil
|
||||||
i.log.Info("Histories have been fully indexed", "last", lastID-1)
|
i.log.Info("State histories have been fully indexed", i.getHistoryRangeInfo(lastID-1)...)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Adjust the indexing target and relaunch the process
|
// Adjust the indexing target and relaunch the process
|
||||||
|
|
@ -448,7 +489,7 @@ func (i *indexIniter) run(lastID uint64) {
|
||||||
case <-done:
|
case <-done:
|
||||||
if checkDone() {
|
if checkDone() {
|
||||||
close(i.done)
|
close(i.done)
|
||||||
i.log.Info("Histories have been fully indexed", "last", lastID)
|
i.log.Info("State histories have been fully indexed", i.getHistoryRangeInfo(lastID)...)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Relaunch the background runner if some tasks are left
|
// Relaunch the background runner if some tasks are left
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue