Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[x/merkledb] Prefetcher interface #2167

Merged
merged 2 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
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
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.

Loading