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
Improve private chains tracking #348
Conversation
src/zen/delay.cpp
Outdated
{ | ||
// blocks on tip get penalty reduced by 1; | ||
// others get penalty increased proportionally to distance from tip | ||
return std::max<int>((activeChainHeight - newBlock.nHeight),-1); |
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 more compact than before but we have not the trace anymore; should we keep it?
src/zen/delay.cpp
Outdated
{ | ||
// blocks on tip get penalty reduced by 1; | ||
// other blocks get penalty increased proportionally to distance from tip | ||
int64_t blockDelay = std::max<int64_t>((activeChainHeight - newBlock.nHeight),int64_t(-1)); |
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.
Is this code behaving the same way if for example activeChainHeight is MIN_INT64 and newBlock.height is MIN_INT64 +1?
Why this PR needed this change?
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.
Change is purely to improve readability, I can roll it back should there not be agreement on such improvement.
Moreover this function is called uniquely by AddToBlockIndex
, with activeChainHeight
set to chainActive.Height()
. chainActive.Height()
is either positive, or -1 (at start, when no block has been added yet). In both cases, the value far away for int64_t boundaries, which would cause the refactored code to diverge from the original
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.
Reverted change as agree offline
To be rebased on top of current development to make a new CI run pass, ready to be merged once CI passes. |
6f1b906
to
cabf249
Compare
Not merging until I had a chance to look at #366 |
In cases where 2 branches have the same length, the 'active' branch is not guaranteed to be at list index 0 in the getchaintips response. Fixed by sorting the list on 'status' k:v.
Along @cronicc indications we are going to extend getchaintips with a --with-penalties=true/false paramenter to include, for each branch: