Skip to content

Commit

Permalink
tweak(plainstate): add close func to close cursors (#10368)
Browse files Browse the repository at this point in the history
If repeatedly using the plainstate in an iteration you can end up with
so many cursors that tx.Rollback/Commit takes a very long time. The fix
is to clean up the cursors as you go with Close() on the plainstate.
  • Loading branch information
revitteth authored May 16, 2024
1 parent 059f8c8 commit c389c6b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions core/state/plain_readonly.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ func NewPlainState(tx kv.Tx, blockNr uint64, systemContractLookup map[libcommon.
return ps
}

func (s *PlainState) Close() {
s.accHistoryC.Close()
s.storageHistoryC.Close()
s.accChangesC.Close()
s.accHistoryC.Close()
}

func (s *PlainState) SetTrace(trace bool) {
s.trace = trace
}
Expand Down

0 comments on commit c389c6b

Please sign in to comment.