Skip to content

Commit

Permalink
[x/merkledb] Prefetcher interface (#2167)
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick-ogrady authored Oct 13, 2023
1 parent 007f98d commit 50f131e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
14 changes: 14 additions & 0 deletions x/merkledb/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,27 @@ type RangeProofer interface {
CommitRangeProof(ctx context.Context, start, end maybe.Maybe[[]byte], proof *RangeProof) error
}

type Prefetcher interface {
// PrefetchPath attempts to load all trie nodes on the path of [key]
// into the cache.
PrefetchPath(key []byte) error

// PrefetchPaths attempts to load all trie nodes on the paths of [keys]
// into the cache.
//
// Using PrefetchPaths can be more efficient than PrefetchPath because
// the underlying view used to compute each path can be reused.
PrefetchPaths(keys [][]byte) error
}

type MerkleDB interface {
database.Database
Trie
MerkleRootGetter
ProofGetter
ChangeProofer
RangeProofer
Prefetcher
}

type Config struct {
Expand Down
28 changes: 28 additions & 0 deletions x/merkledb/mock_db.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 50f131e

Please sign in to comment.