@@ -44,7 +44,7 @@ type DumpCollector interface {
44
44
// OnRoot is called with the state root
45
45
OnRoot (common.Hash )
46
46
// OnAccount is called once for each account in the trie
47
- OnAccount (common.Address , DumpAccount )
47
+ OnAccount (* common.Address , DumpAccount )
48
48
}
49
49
50
50
// DumpAccount represents an account in the state.
@@ -72,8 +72,10 @@ func (d *Dump) OnRoot(root common.Hash) {
72
72
}
73
73
74
74
// OnAccount implements DumpCollector interface
75
- func (d * Dump ) OnAccount (addr common.Address , account DumpAccount ) {
76
- d .Accounts [addr ] = account
75
+ func (d * Dump ) OnAccount (addr * common.Address , account DumpAccount ) {
76
+ if addr != nil {
77
+ d .Accounts [* addr ] = account
78
+ }
77
79
}
78
80
79
81
// IteratorDump is an implementation for iterating over data.
@@ -89,8 +91,10 @@ func (d *IteratorDump) OnRoot(root common.Hash) {
89
91
}
90
92
91
93
// OnAccount implements DumpCollector interface
92
- func (d * IteratorDump ) OnAccount (addr common.Address , account DumpAccount ) {
93
- d .Accounts [addr ] = account
94
+ func (d * IteratorDump ) OnAccount (addr * common.Address , account DumpAccount ) {
95
+ if addr != nil {
96
+ d .Accounts [* addr ] = account
97
+ }
94
98
}
95
99
96
100
// iterativeDump is a DumpCollector-implementation which dumps output line-by-line iteratively.
@@ -99,7 +103,7 @@ type iterativeDump struct {
99
103
}
100
104
101
105
// OnAccount implements DumpCollector interface
102
- func (d iterativeDump ) OnAccount (addr common.Address , account DumpAccount ) {
106
+ func (d iterativeDump ) OnAccount (addr * common.Address , account DumpAccount ) {
103
107
dumpAccount := & DumpAccount {
104
108
Balance : account .Balance ,
105
109
Nonce : account .Nonce ,
@@ -108,10 +112,7 @@ func (d iterativeDump) OnAccount(addr common.Address, account DumpAccount) {
108
112
Code : account .Code ,
109
113
Storage : account .Storage ,
110
114
SecureKey : account .SecureKey ,
111
- Address : nil ,
112
- }
113
- if addr != (common.Address {}) {
114
- dumpAccount .Address = & addr
115
+ Address : addr ,
115
116
}
116
117
d .Encode (dumpAccount )
117
118
}
@@ -152,16 +153,20 @@ func (s *StateDB) DumpToCollector(c DumpCollector, conf *DumpConfig) (nextKey []
152
153
CodeHash : data .CodeHash ,
153
154
SecureKey : it .Key ,
154
155
}
155
- addrBytes := s .trie .GetKey (it .Key )
156
+ var (
157
+ addrBytes = s .trie .GetKey (it .Key )
158
+ addr = common .BytesToAddress (addrBytes )
159
+ address * common.Address
160
+ )
156
161
if addrBytes == nil {
157
162
// Preimage missing
158
163
missingPreimages ++
159
164
if conf .OnlyWithAddresses {
160
165
continue
161
166
}
162
- account .SecureKey = it .Key
167
+ } else {
168
+ address = & addr
163
169
}
164
- addr := common .BytesToAddress (addrBytes )
165
170
obj := newObject (s , addr , data )
166
171
if ! conf .SkipCode {
167
172
account .Code = obj .Code (s .db )
@@ -183,7 +188,7 @@ func (s *StateDB) DumpToCollector(c DumpCollector, conf *DumpConfig) (nextKey []
183
188
account .Storage [common .BytesToHash (s .trie .GetKey (storageIt .Key ))] = common .Bytes2Hex (content )
184
189
}
185
190
}
186
- c .OnAccount (addr , account )
191
+ c .OnAccount (address , account )
187
192
accounts ++
188
193
if time .Since (logged ) > 8 * time .Second {
189
194
log .Info ("Trie dumping in progress" , "at" , it .Key , "accounts" , accounts ,
0 commit comments