|
|
|
@ -44,7 +44,7 @@ type DumpCollector interface { |
|
|
|
|
// OnRoot is called with the state root
|
|
|
|
|
OnRoot(common.Hash) |
|
|
|
|
// OnAccount is called once for each account in the trie
|
|
|
|
|
OnAccount(common.Address, DumpAccount) |
|
|
|
|
OnAccount(*common.Address, DumpAccount) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// DumpAccount represents an account in the state.
|
|
|
|
@ -72,8 +72,10 @@ func (d *Dump) OnRoot(root common.Hash) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// OnAccount implements DumpCollector interface
|
|
|
|
|
func (d *Dump) OnAccount(addr common.Address, account DumpAccount) { |
|
|
|
|
d.Accounts[addr] = account |
|
|
|
|
func (d *Dump) OnAccount(addr *common.Address, account DumpAccount) { |
|
|
|
|
if addr != nil { |
|
|
|
|
d.Accounts[*addr] = account |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// IteratorDump is an implementation for iterating over data.
|
|
|
|
@ -89,8 +91,10 @@ func (d *IteratorDump) OnRoot(root common.Hash) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// OnAccount implements DumpCollector interface
|
|
|
|
|
func (d *IteratorDump) OnAccount(addr common.Address, account DumpAccount) { |
|
|
|
|
d.Accounts[addr] = account |
|
|
|
|
func (d *IteratorDump) OnAccount(addr *common.Address, account DumpAccount) { |
|
|
|
|
if addr != nil { |
|
|
|
|
d.Accounts[*addr] = account |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// iterativeDump is a DumpCollector-implementation which dumps output line-by-line iteratively.
|
|
|
|
@ -99,7 +103,7 @@ type iterativeDump struct { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// OnAccount implements DumpCollector interface
|
|
|
|
|
func (d iterativeDump) OnAccount(addr common.Address, account DumpAccount) { |
|
|
|
|
func (d iterativeDump) OnAccount(addr *common.Address, account DumpAccount) { |
|
|
|
|
dumpAccount := &DumpAccount{ |
|
|
|
|
Balance: account.Balance, |
|
|
|
|
Nonce: account.Nonce, |
|
|
|
@ -108,10 +112,7 @@ func (d iterativeDump) OnAccount(addr common.Address, account DumpAccount) { |
|
|
|
|
Code: account.Code, |
|
|
|
|
Storage: account.Storage, |
|
|
|
|
SecureKey: account.SecureKey, |
|
|
|
|
Address: nil, |
|
|
|
|
} |
|
|
|
|
if addr != (common.Address{}) { |
|
|
|
|
dumpAccount.Address = &addr |
|
|
|
|
Address: addr, |
|
|
|
|
} |
|
|
|
|
d.Encode(dumpAccount) |
|
|
|
|
} |
|
|
|
@ -152,16 +153,20 @@ func (s *StateDB) DumpToCollector(c DumpCollector, conf *DumpConfig) (nextKey [] |
|
|
|
|
CodeHash: data.CodeHash, |
|
|
|
|
SecureKey: it.Key, |
|
|
|
|
} |
|
|
|
|
addrBytes := s.trie.GetKey(it.Key) |
|
|
|
|
var ( |
|
|
|
|
addrBytes = s.trie.GetKey(it.Key) |
|
|
|
|
addr = common.BytesToAddress(addrBytes) |
|
|
|
|
address *common.Address |
|
|
|
|
) |
|
|
|
|
if addrBytes == nil { |
|
|
|
|
// Preimage missing
|
|
|
|
|
missingPreimages++ |
|
|
|
|
if conf.OnlyWithAddresses { |
|
|
|
|
continue |
|
|
|
|
} |
|
|
|
|
account.SecureKey = it.Key |
|
|
|
|
} else { |
|
|
|
|
address = &addr |
|
|
|
|
} |
|
|
|
|
addr := common.BytesToAddress(addrBytes) |
|
|
|
|
obj := newObject(s, addr, data) |
|
|
|
|
if !conf.SkipCode { |
|
|
|
|
account.Code = obj.Code(s.db) |
|
|
|
@ -183,7 +188,7 @@ func (s *StateDB) DumpToCollector(c DumpCollector, conf *DumpConfig) (nextKey [] |
|
|
|
|
account.Storage[common.BytesToHash(s.trie.GetKey(storageIt.Key))] = common.Bytes2Hex(content) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
c.OnAccount(addr, account) |
|
|
|
|
c.OnAccount(address, account) |
|
|
|
|
accounts++ |
|
|
|
|
if time.Since(logged) > 8*time.Second { |
|
|
|
|
log.Info("Trie dumping in progress", "at", it.Key, "accounts", accounts, |
|
|
|
|