Commit graph

3 commits

Author SHA1 Message Date
Austin Larson
7342b55267
feat(triedb): expose backend for custom use (#183)
## Why this should be merged

To override the standard trie behavior for custom databases in
`core/state/database.go`, custom methods may need to be defined on the
backend database.

## How this works

Exposes `backend` interface for the API

## How this was tested

No tests necessary - isn't used in `libevm`.
2025-05-30 14:29:56 -04:00
Quentin McGaw
87a2d57b96
chore!(triedb): remove config argument for DBConstructor (#167) 2025-03-25 11:22:59 +01:00
Arran Schlosberg
594abd9f42
feat: triedb.Config support for arbitrary backend implementations (#70)
## Why this should be merged

Allow `ava-labs/coreth` to use arbitrary `triedb` database
implementations.

## How this works

Introduces `HashBackend` and `PathBackend` interfaces that
`triedb.Database` type-asserts to instead of `hashdb.Database` and
`pathdb.Backend` respectively. Other interfaces are introduced to avoid
having to modify `{hash,path}db.Database.Reader()` return values.

The explicit `DBOverride` field means that we don't have to modify any
of the `triedb` constructor beyond adding a single line immediately
before the return. This leaves all modifications of original files
entirely mechanistic. This is, however, at the expense of compile-time
guarantees of the overriding database being either a `HashBackend` or a
`PathBackend`.

## How this was tested

Unit test demonstrating override + plumbing.

---------

Co-authored-by: Darioush Jalali <darioush.jalali@avalabs.org>
2024-11-14 16:55:07 +00:00