Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions db/state/domain_committed.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ func (dt *DomainRoTx) commitmentValTransformDomain(rng MergeRange, accounts, sto
// The merged file is read-only for the duration of this transformer, so
// (key → offset) is invariant within the closure. Both maps live only
// for the merge of one range; no cross-merge state.
const cacheMaxEntries = 100_000
storageKeyCache := make(map[string]uint64)
accountKeyCache := make(map[string]uint64)

Expand Down Expand Up @@ -371,6 +372,9 @@ func (dt *DomainRoTx) commitmentValTransformDomain(rng MergeRange, accounts, sto

return nil, fmt.Errorf("replacement not found for storage %x", auxBuf)
}
if len(storageKeyCache) >= cacheMaxEntries {
clear(storageKeyCache)
}
storageKeyCache[string(auxBuf)] = shortenedKeyOffset
}
shortened = EncodeReferenceKey(shortened[:0], shortenedKeyOffset)
Expand Down Expand Up @@ -407,6 +411,9 @@ func (dt *DomainRoTx) commitmentValTransformDomain(rng MergeRange, accounts, sto
"shortened", hex.EncodeToString(key), "toReplace", hex.EncodeToString(auxBuf))
return nil, fmt.Errorf("replacement not found for account %x", auxBuf)
}
if len(accountKeyCache) >= cacheMaxEntries {
clear(accountKeyCache)
}
accountKeyCache[string(auxBuf)] = shortenedKeyOffset
}
shortened = EncodeReferenceKey(shortened[:0], shortenedKeyOffset)
Expand Down
Loading