refactor: Hide lifetimes from external crates, support error cloning#145
refactor: Hide lifetimes from external crates, support error cloning#145BrianBland wants to merge 1 commit intomainfrom
Conversation
🟡 Heimdall Review Status
|
|
|
||
| #[derive(Debug)] | ||
| #[derive(Clone, Debug)] | ||
| pub enum Error { |
There was a problem hiding this comment.
It's very rare for errors to implement Clone, which is why most errors (in the std lib too) don't implement it. Is there a specific reason why we want them here? The PR description mentions "usability reasons", but I struggle to find places where errors are cloned instead of being simply propagated.
There was a problem hiding this comment.
This was introduced for seamless compatibility with Reth, as they appear to clone errors. I'll double check whether or not this is truly necessary
There was a problem hiding this comment.
Upon further review this mostly stems from Reth cloning Results (example) including the ProviderError
We don't really need to embed the raw TrieDB Error inside of the ProviderError, and can instead just stringify this to remove the need for error cloning.
| } | ||
| } | ||
|
|
||
| impl Database { |
There was a problem hiding this comment.
Instead of rewriting all the code to use self.inner. instead of self., I would suggest simply changing impl Database to impl DatabaseInner. The only methods that need to stay inside impl Database are the constructors (create and new). Everything else can be transparently delegated by Deref
There was a problem hiding this comment.
I believe this would require making DatabaseInner public, which we probably want to avoid
There was a problem hiding this comment.
Another option might be to make Transaction accept a generic DB which implements Deref<Database>, so that we can use &Database or Arc<Database> as needed.
Improve usability of TrieDB as a crate by making the following external-facing changes:
Arcof a database handleThis re-introduces
DatabaseInner, withDatabasesimply holding anArcof the inner struct.Replaces #108