-
Notifications
You must be signed in to change notification settings - Fork 12
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
Handle Extension-nodes in Iterator #430
Conversation
richardpringle
commented
Dec 11, 2023
- Move MerkleStream to submodule
- Make MerkleStream handle branches with values
- Stop prefetching next node in iterator
61307e0
to
0431824
Compare
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.
Partial review
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.
Still need to review the algorithm more, but I added a few questions in the meantime.
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.
Round 2 of questions
487fe8d
to
7dae9e3
Compare
6861cf3
to
980fed5
Compare
.map_err(|e| api::Error::InternalError(Box::new(e))) | ||
start_key: Box<[u8]>, | ||
) -> merkle::MerkleKeyValueStream<'_, S, Bincode> { | ||
self.merkle.iter_from(self.header.kv_root, start_key) |
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.
This is a significant improvement to the API. It was such a pain specifying the type on the None
when it could be any number of things. It's too bad there's no default
generic, like with structs and enums.
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.
yeah, I like that.
@@ -1264,7 +1265,7 @@ impl<S: ShaleStore<Node> + Send + Sync, T> Merkle<S, T> { | |||
.map_err(|e| api::Error::InternalError(Box::new(e)))?; | |||
let limit = limit.map(|old_limit| old_limit - 1); | |||
|
|||
let mut middle = vec![(first_key, first_data)]; | |||
let mut middle = vec![(first_key.into_vec(), first_data)]; |
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.
I wasn't sure about this, but we can change it later. into_vec
does not allocate.
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.
My review was mostly focus on the algorithm and the test cases coverage and all comments are nits that can be ignored or addressed in a follow up.
.map_err(|e| api::Error::InternalError(Box::new(e))) | ||
start_key: Box<[u8]>, | ||
) -> merkle::MerkleKeyValueStream<'_, S, Bincode> { | ||
self.merkle.iter_from(self.header.kv_root, start_key) |
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.
yeah, I like that.
} | ||
|
||
#[tokio::test] | ||
async fn start_at_key_greater_than_all_others() { |
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.
thanks a lot for the thorough test lists! On top of that may be start_at_key_smaller_than_all_others
? I guess this may be already covered, but just to make it explicitly covered.
} | ||
|
||
enum NodeRef<'a> { | ||
New(ObjRef<'a>), |
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.
❤️
Ok(next) | ||
} | ||
|
||
fn find_next_node_with_data<'a, S: ShaleStore<Node>, T>( |
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.
nit: as the core function, I feel it deserves some high level comments describe how things work.
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.
Removing "requested changes" status. Hao has completed the review here.