-
Notifications
You must be signed in to change notification settings - Fork 1.7k
chore(trie): Stateful DatabaseTrieWitness
#16900
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Rjected do we still need/want this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Rjected do we still need/want this?
This would be nice, although the other PRs for this refactor had issues with cyclic deps that I think we should address with some reorganization first. One question about why this needs a FnOnce mainly, and another comment about removing generics from one of the new fns
/// Applies given operation on and sets the trie cursor factory. | ||
pub fn with_trie_cursor_factory<TF, F>(self, f: F) -> TrieWitness<TF, H> | ||
where | ||
F: FnOnce(T) -> TF, | ||
{ | ||
TrieWitness { | ||
trie_cursor_factory, | ||
trie_cursor_factory: f(self.trie_cursor_factory), | ||
hashed_cursor_factory: self.hashed_cursor_factory, | ||
prefix_sets: self.prefix_sets, | ||
always_include_root_node: self.always_include_root_node, | ||
witness: self.witness, | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did we have to make this method into one that requires a FnOnce
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see commit at HEAD^
, uglier syntax
/// Set the hashed cursor factory. | ||
pub fn with_hashed_cursor_factory<HF>(self, hashed_cursor_factory: HF) -> TrieWitness<T, HF> { | ||
/// Applies given operation on and sets the hashed cursor factory. | ||
pub fn with_hashed_cursor_factory<HF, F>(self, f: F) -> TrieWitness<T, HF> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same q here for FnOnce
/// Constructs a new instance from given database transaction. | ||
pub fn from_tx<'a, TX>(tx: &'a TX) -> Self | ||
where | ||
T: From<&'a TX>, | ||
H: From<&'a TX>, | ||
{ | ||
Self::new(T::from(tx), H::from(tx)) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we make this a method on TrieWitness<DatabaseTrieCursorFactory<..>, DatabaseHashedCursorFactory<..>>
instead of making this fully generic with From
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cyclic dep issue
Closes #15481