Skip to content

Commit 50f131e

Browse files
[x/merkledb] Prefetcher interface (#2167)
1 parent 007f98d commit 50f131e

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

x/merkledb/db.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,27 @@ type RangeProofer interface {
114114
CommitRangeProof(ctx context.Context, start, end maybe.Maybe[[]byte], proof *RangeProof) error
115115
}
116116

117+
type Prefetcher interface {
118+
// PrefetchPath attempts to load all trie nodes on the path of [key]
119+
// into the cache.
120+
PrefetchPath(key []byte) error
121+
122+
// PrefetchPaths attempts to load all trie nodes on the paths of [keys]
123+
// into the cache.
124+
//
125+
// Using PrefetchPaths can be more efficient than PrefetchPath because
126+
// the underlying view used to compute each path can be reused.
127+
PrefetchPaths(keys [][]byte) error
128+
}
129+
117130
type MerkleDB interface {
118131
database.Database
119132
Trie
120133
MerkleRootGetter
121134
ProofGetter
122135
ChangeProofer
123136
RangeProofer
137+
Prefetcher
124138
}
125139

126140
type Config struct {

x/merkledb/mock_db.go

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)