Skip to content

Conversation

r8921039
Copy link
Contributor

The return value of findFork is an ancestor of the specified block only when specified block is not on the active chain. When it is on the active chain, the return value is the specified block itself, not an ancestor of it.

@gmaxwell
Copy link
Contributor

Return height of the highest block on the chain that is or has an ancestor

"is or has an ancestor" doesn't make much sense to me. The function is returning the highest common point, if the block is on the chain, that's obviously itself. The comment in chain.h is correct and I think not confusing: Find the last common block between this chain and a block index entry.

@fanquake fanquake added the Docs label Mar 24, 2019
@maflcko maflcko requested a review from ryanofsky March 25, 2019 02:12
@r8921039
Copy link
Contributor Author

Similarly, the following comment is true only if the locator is not created by a block on the active chain.

    //! Return height of the latest block common to locator and chain, which
    //! is guaranteed to be an ancestor of the block used to create the
    //! locator.
    virtual Optional<int> findLocatorFork(const CBlockLocator& locator) = 0;

@ryanofsky
Copy link
Contributor

ryanofsky commented Mar 25, 2019

@r8921039, I wrote these comments and I can see how they are confusing. I wrote "ancestor" here when I really meant "ancestor-or-self" because it seemed less awkward (similar to how people write ⊂ instead of ⊆ in math for convenience, even though it can be less clear if you don't know the context).

I think "highest block on the chain that is or has an ancestor of the specified block" is hard to parse, though. Maybe it would be better to change these comments to:

  • findFork: Return height of the specified block if it is on the chain, otherwise return the height of the highest block on chain that's an ancestor of the specified block, or nullopt if there is no common ancestor.
  • findLocatorFork: Return height of the highest block on chain in common with the locator (which will either be the original block used to create the locator, or one of its ancestors.)

@r8921039
Copy link
Contributor Author

@ryanofsky Thank you very much for your response and suggestions. The PR is updated accordingly.

Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK b837d66

@maflcko
Copy link
Member

maflcko commented Mar 25, 2019

Please squash your commits according to https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#squashing-commits

… when the specified block is on the active chain

update with suggested comment text from the reviewers
@r8921039 r8921039 force-pushed the fix_findFork_comment branch from b837d66 to c968780 Compare March 25, 2019 21:29
@r8921039
Copy link
Contributor Author

@MarcoFalke Yes sir, done as instructed.

@promag
Copy link
Contributor

promag commented Mar 26, 2019

utACK c968780, however comment could be shorter.

Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK c968780. Only change since last review is squash

@r8921039
Copy link
Contributor Author

r8921039 commented Apr 6, 2019

Would someone be willing to give a bit more love to this PR... Thanks.

@ryanofsky
Copy link
Contributor

This could just be merged I think. Documentation update with no change in meaning.

@r8921039
Copy link
Contributor Author

@MarcoFalke Do we need more utACK to proceed? If you think so, I will try asking on IRC. Thanks.

@maflcko maflcko merged commit c968780 into bitcoin:master Apr 10, 2019
maflcko pushed a commit that referenced this pull request Apr 10, 2019
c968780 [docs] fix comment: the return value of findFork is _not_ an ancestor when the specified block is on the active chain (r8921039)

Pull request description:

  The return value of findFork is an ancestor of the specified block only when specified block is _not_ on the active chain. When it is on the active chain, the return value is the specified block itself, not an ancestor of it.

ACKs for commit c96878:
  promag:
    utACK c968780, however comment could be shorter.
  ryanofsky:
    utACK c968780. Only change since last review is squash

Tree-SHA512: bb05d734059898784c4a59b5b0344719eb4dfb2d49a0f7f705fcb2eb630702e66be81c01299185faf0c219fa9f9aa64cbdf6d5f91e0b3dce0ff420909a454a18
@r8921039
Copy link
Contributor Author

Thanks a lot guys! :)

@r8921039 r8921039 deleted the fix_findFork_comment branch April 15, 2019 06:25
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Dec 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants