Skip to content

Commit 9d9ca45

Browse files
committed
triedb/pathdb: derive state set without holding the lock
1 parent 99bb612 commit 9d9ca45

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

triedb/pathdb/disklayer.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,10 @@ func (dl *diskLayer) revert(h *history) (*diskLayer, error) {
302302
if err != nil {
303303
return nil, err
304304
}
305+
// Derive the state modification set from the history, keyed by the hash
306+
// of the account address and the storage key.
307+
accounts, storages := h.stateSet()
308+
305309
// Mark the diskLayer as stale before applying any mutations on top.
306310
dl.lock.Lock()
307311
defer dl.lock.Unlock()
@@ -314,7 +318,6 @@ func (dl *diskLayer) revert(h *history) (*diskLayer, error) {
314318
// needs to be reverted is not yet flushed and cached in node
315319
// buffer, otherwise, manipulate persistent state directly.
316320
if !dl.buffer.empty() {
317-
accounts, storages := h.stateSet()
318321
err := dl.buffer.revertTo(dl.db.diskdb, nodes, accounts, storages)
319322
if err != nil {
320323
return nil, err

0 commit comments

Comments
 (0)