Skip to content

Commit a6e95c4

Browse files
committed
feat(triedb): expose backend for custom use
1 parent c2e6df1 commit a6e95c4

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

triedb/database.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ var HashDefaults = &Config{
4747
HashDB: hashdb.Defaults,
4848
}
4949

50-
// backend defines the methods needed to access/update trie nodes in different
51-
// state scheme.
52-
type backend interface {
50+
// Backend defines the methods needed to access/update trie nodes in different
51+
// state schemes.
52+
type Backend interface {
5353
// Scheme returns the identifier of used storage scheme.
5454
Scheme() string
5555

@@ -87,7 +87,7 @@ type Database struct {
8787
config *Config // Configuration for trie database
8888
diskdb ethdb.Database // Persistent database to store the snapshot
8989
preimages *preimageStore // The store for caching preimages
90-
backend backend // The backend for managing trie nodes
90+
backend Backend // The backend for managing trie nodes
9191
}
9292

9393
// NewDatabase initializes the trie database with default settings, note
@@ -343,3 +343,9 @@ func (db *Database) SetBufferSize(size int) error {
343343
func (db *Database) IsVerkle() bool {
344344
return db.config.IsVerkle
345345
}
346+
347+
// Backend returns the underlying backend of the trie database, which
348+
// implements the methods for accessing additional custom methods.
349+
func (db *Database) Backend() Backend {
350+
return db.backend
351+
}

triedb/database.libevm.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929
// BackendDB defines the intersection of methods shared by [hashdb.Database] and
3030
// [pathdb.Database]. It is defined to export an otherwise internal type used by
3131
// the non-libevm geth implementation.
32-
type BackendDB backend
32+
type BackendDB Backend
3333

3434
// A ReaderProvider exposes its underlying Reader as an interface. Both
3535
// [hashdb.Database] and [pathdb.Database] return concrete types so Go's lack of

0 commit comments

Comments
 (0)