Avoid unused call to GuessVerificationProgress in NotifyHeaderTip #17250

pull MarcoFalke wants to merge 1 commits into bitcoin:master from MarcoFalke:1910-NoWrongGuess changing 1 files +1 −1
  1. MarcoFalke commented at 1:18 PM on October 25, 2019: member

    GuessVerificationProgress for a header (not a block) is always 0 because the number of txs in the block can not be determined from the header alone. Anyway, this result was never used, so we can optimize this call by hardcoding 0.

    This is the next commit in a series of changes toward removing nChainTx (see #14863, #13875)

  2. Avoid unused call to GuessVerificationProgress in NotifyHeaderTip fa398091b7
  3. MarcoFalke added the label Refactoring on Oct 25, 2019
  4. promag commented at 3:57 PM on October 27, 2019: member

    Anyway, this result was never used

    Isn't progress used here even for an header notification https://github.com/bitcoin/bitcoin/blob/be50469217bd775c4305938634c32e5932f47841/src/qt/bitcoingui.cpp#L991

    is always 0 because the number of txs in the block can not be determined from the header alone

    Right, nChainTx is not known, but I fail to see how it's zero: https://github.com/bitcoin/bitcoin/blob/be50469217bd775c4305938634c32e5932f47841/src/validation.cpp#L5061-L5076

  5. MarcoFalke commented at 4:15 PM on October 27, 2019: member

    Right, nChainTx is not known, but I fail to see how it's zero:

    It is initialized to zero: https://dev.visucore.com/bitcoin/doxygen/class_c_block_index.html#af3c6d6dd8a7579e5ce516d94b98d2db5 and only set when we have the block downloaded. Without having the transactions downloaded, it is currently impossible to know how many txs there are in the block.

  6. MarcoFalke commented at 4:16 PM on October 27, 2019: member

    Then GuessVerificationProgress will return zero, because zero divided by something is still zero

  7. promag commented at 4:24 PM on October 27, 2019: member

    It is initialized to zero

    Code review ACK fa398091b7ad683dfd3cd3c2cd030eaf9f336737, missed that.

  8. laanwj commented at 11:51 AM on October 28, 2019: member

    ACK fa398091b7ad683dfd3cd3c2cd030eaf9f336737

  9. laanwj referenced this in commit a25945318f on Oct 28, 2019
  10. laanwj merged this on Oct 28, 2019
  11. laanwj closed this on Oct 28, 2019

  12. MarcoFalke deleted the branch on Nov 1, 2019
  13. deadalnix referenced this in commit 7e43e1683d on Oct 30, 2020
  14. DrahtBot locked this on Dec 16, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-17 06:14 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me