Skip to content

Commit

Permalink
core/state: small trie prefetcher nits (#28183)
Browse files Browse the repository at this point in the history
Small trie prefetcher nits
  • Loading branch information
aaronbuchwald authored and ucwong committed Sep 30, 2023
1 parent 94d1f5b commit 23e28f8
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions core/state/trie_prefetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ var (
// Note, the prefetcher's API is not thread safe.
type triePrefetcher struct {
db Database // Database to fetch trie nodes through
root common.Hash // Root hash of theaccount trie for metrics
fetches map[common.Hash]Trie // Partially or fully fetcher tries
root common.Hash // Root hash of the account trie for metrics
fetches map[common.Hash]Trie // Partially or fully fetched tries. Only populated for inactive copies.
fetchers map[common.Hash]*subfetcher // Subfetchers for each trie

deliveryMissMeter metrics.Meter
Expand Down Expand Up @@ -191,6 +191,14 @@ func (p *triePrefetcher) used(root common.Hash, used [][]byte) {
}
}

// trieID returns an unique trie identifier consists the trie owner and root hash.
func (p *triePrefetcher) trieID(owner common.Hash, root common.Hash) string {
trieID := make([]byte, common.HashLength*2)
copy(trieID, owner.Bytes())
copy(trieID[common.HashLength:], root.Bytes())
return string(trieID)
}

// subfetcher is a trie fetcher goroutine responsible for pulling entries for a
// single trie. It is spawned when a new root is encountered and lives until the
// main prefetcher is paused and either all requested items are processed or if
Expand Down

0 comments on commit 23e28f8

Please sign in to comment.