-
Notifications
You must be signed in to change notification settings - Fork 992
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
Retrieve outputs within a block height range #3103
Retrieve outputs within a block height range #3103
Conversation
…indices between blocks
Decided it was easier and more consistent to just add a new API function that returns the pmmr indices corresponding to a range of blocks, and then just passing that to the existing |
|
||
match right_path_element!(req) { | ||
"roots" => result_to_response(self.get_roots()), | ||
"lastoutputs" => result_to_response(self.get_last_n_output(last_n)), | ||
"lastrangeproofs" => result_to_response(self.get_last_n_rangeproof(last_n)), | ||
"lastkernels" => result_to_response(self.get_last_n_kernel(last_n)), | ||
"outputs" => result_to_response(self.outputs(start_index, max)), | ||
"outputs" => result_to_response(self.outputs(start_index, end_index, max)), | ||
"heightstopmmr" => result_to_response( |
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.
Subjective comment but "heightstopmmr" is a confusing name... "height stop mmr"?
Also not convinced we want to leak implementation details like this?
Seems like (at least intuitively) that you'd want to get outputs based on height directly, rather than retrieving the intermediate mmr positions.
Once we start doing things based on positions we inevitably go down the path of "is this 1-indexed or 0-index" and "is this leaf insertion indices or actual positions in the MMR"? And it is potientially confusing here because we are looking for leaves, the outputs themselves but via mmr positions, and presumably 1-indexed.
I'd much rather expose this via the api based on block height and keep the MMR implementation hidden behind the api.
Going to merge based on discussions below. Note this change actually makes the PMMR scan a bit more consistent as it uses actual position exclusively as opposed to index. Can come back to this later on during a general cleanup on what the API exposes:
|
Related to mimblewimble/grin-wallet#246
The idea is to ensure there's an API to scan outputs committed within a specified range of blocks. This will be used during the wallet update process to scan the output set (similarly to how the current
check_repair
function works,) and and re-create any outputs that are missing due to forks or multiple wallets using the same seed.This PR simply adds the function to the API, WIP until I've verified and tweaked against the current wallet PR.