This repository was archived by the owner on May 23, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -147,14 +147,20 @@ def load_state(env, alloc):
147
147
count = 0
148
148
print "Start loading state from snapshot"
149
149
for addr in alloc :
150
+ print "[%d] loading account %s" % (count , addr )
150
151
account = alloc [addr ]
151
152
acct = Account .blank_account (db , env .config ['ACCOUNT_INITIAL_NONCE' ])
152
153
if len (account ['storage' ]) > 0 :
153
154
t = SecureTrie (Trie (db , BLANK_ROOT ))
155
+ c = 0
154
156
for k in account ['storage' ]:
155
157
v = account ['storage' ][k ]
156
158
enckey = zpad (decode_hex (k ), 32 )
157
159
t .update (enckey , decode_hex (v ))
160
+ c += 1
161
+ if c % 1000 and len (db .db_service .uncommitted ) > 50000 :
162
+ print "%d uncommitted. committing..." % len (db .db_service .uncommitted )
163
+ db .commit ()
158
164
acct .storage = t .root_hash
159
165
if account ['nonce' ]:
160
166
acct .nonce = int (account ['nonce' ])
@@ -164,9 +170,6 @@ def load_state(env, alloc):
164
170
acct .code = decode_hex (account ['code' ])
165
171
state .update (decode_hex (addr ), rlp .encode (acct ))
166
172
count += 1
167
- if count % 1000 == 0 :
168
- db .commit ()
169
- print "[%d] loaded account %s" % (count , addr )
170
173
db .commit ()
171
174
return state
172
175
You can’t perform that action at this time.
0 commit comments