-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed as not planned
Labels
A-dbRelated to the databaseRelated to the databaseA-trieRelated to Merkle Patricia Trie implementationRelated to Merkle Patricia Trie implementationC-enhancementNew feature or requestNew feature or requestD-good-first-issueNice and easy! A great choice to get startedNice and easy! A great choice to get started
Description
Describe the feature
Right now DatabaseStorageRoot has an associated TX type and takes &'a Self::TX on every method:
reth/crates/trie/db/src/storage.rs
Lines 14 to 28 in ca862ab
| /// Extends [`StorageRoot`] with operations specific for working with a database transaction. | |
| pub trait DatabaseStorageRoot<'a, TX> { | |
| /// Create a new storage root calculator from database transaction and raw address. | |
| fn from_tx(tx: &'a TX, address: Address) -> Self; | |
| /// Create a new storage root calculator from database transaction and hashed address. | |
| fn from_tx_hashed(tx: &'a TX, hashed_address: B256) -> Self; | |
| /// Calculates the storage root for this [`HashedStorage`] and returns it. | |
| fn overlay_root( | |
| tx: &'a TX, | |
| address: Address, | |
| hashed_storage: HashedStorage, | |
| ) -> Result<B256, StorageRootError>; | |
| } |
This is not necessary, instead we can make this into a regular trait that is stateful and takes &self. For example it would look like:
/// Extends [`StorageRoot`] with operations specific for working with a database transaction.
pub trait DatabaseStorageRoot {
/// Create a new storage root calculator from database transaction and raw address.
fn from_tx(&self, address: Address) -> Self;
/// Create a new storage root calculator from database transaction and hashed address.
fn from_tx_hashed(&self, hashed_address: B256) -> Self;
/// Calculates the storage root for this [`HashedStorage`] and returns it.
fn overlay_root(
&self,
address: Address,
hashed_storage: HashedStorage,
) -> Result<B256, StorageRootError>;
}And the implementers can have a from_tx method on the struct itself
Additional context
No response
Metadata
Metadata
Assignees
Labels
A-dbRelated to the databaseRelated to the databaseA-trieRelated to Merkle Patricia Trie implementationRelated to Merkle Patricia Trie implementationC-enhancementNew feature or requestNew feature or requestD-good-first-issueNice and easy! A great choice to get startedNice and easy! A great choice to get started
Type
Projects
Status
Done