Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions core/state/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package state
import (
"encoding/json"
"fmt"
"time"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
Expand Down Expand Up @@ -112,11 +113,16 @@ func (d iterativeDump) OnRoot(root common.Hash) {
}

func (s *StateDB) DumpToCollector(c DumpCollector, excludeCode, excludeStorage, excludeMissingPreimages bool, start []byte, maxResults int) (nextKey []byte) {
missingPreimages := 0
c.OnRoot(s.trie.Hash())

var count int
it := trie.NewIterator(s.trie.NodeIterator(start))
var (
missingPreimages = 0
count int
it = trie.NewIterator(s.trie.NodeIterator(start))
logged = time.Now()
startTime = time.Now()
)

for it.Next() {
var data Account
if err := rlp.DecodeBytes(it.Value, &data); err != nil {
Expand All @@ -129,6 +135,12 @@ func (s *StateDB) DumpToCollector(c DumpCollector, excludeCode, excludeStorage,
CodeHash: common.Bytes2Hex(data.CodeHash),
}
addrBytes := s.trie.GetKey(it.Key)
if time.Since(logged) > 10*time.Second {
logged = time.Now()
log.Info("State iteration in progress",
"at", fmt.Sprintf("%x", addrBytes),
"elapsed", common.PrettyDuration(time.Since(startTime)))
}
if addrBytes == nil {
// Preimage missing
missingPreimages++
Expand Down