-
Notifications
You must be signed in to change notification settings - Fork 27
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
feat(consensus): eliminate block ties #673
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -618,6 +618,11 @@ def get_best_block_tips(self, timestamp: Optional[float] = None, *, skip_cache: | |
elif meta.score > best_score: | ||
best_score = meta.score | ||
best_tip_blocks = [block_hash] | ||
|
||
# XXX: if there's more than one we filter it so it's the smallest hash | ||
if len(best_tip_blocks) > 1: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we create an issue to refactor this method and simply store the current best block in the storage? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. #540 sort of does this by using the height-index, but because it's not using this PR as a base it does this incorrectly and hides other tips, after this PR that change would be correct |
||
best_tip_blocks = [min(best_tip_blocks)] | ||
|
||
if timestamp is None: | ||
self._best_block_tips_cache = best_tip_blocks[:] | ||
return best_tip_blocks | ||
|
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.
Should we allow the caller to choose whether they want to get just one or all of them?
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 think that could make sense as a new method, like
get_all_block_tips
, instead ofget_best_block_tips
. But currently that method wouldn't be used anywhere else, and when removing the tips indexes, it would be more convenient if we didn't have to maintain that method.