Remove unnecessary call to CTransaction::IsCoinBase() #16103

pull promag wants to merge 1 commits into bitcoin:master from promag:2015-05-avoid-iscoinbase changing 1 files +2 −2
  1. promag commented at 3:38 PM on May 27, 2019: member
  2. Remove unnecessary call to CTransaction::IsCoinBase() c4ccf55ad6
  3. fanquake added the label Refactoring on May 27, 2019
  4. fanquake added the label Validation on May 27, 2019
  5. promag commented at 3:39 PM on May 27, 2019: member

    Am I missing something? Is there a case where this change is wrong?

  6. Empact commented at 7:52 PM on May 27, 2019: member

    -0 IMO better to rely on the definition in IsCoinBase. I think the line you cite may be for coherence with https://github.com/bitcoin/bitcoin/blob/76e2cded477bc483ec610212bdadf21fe35292d4/src/validation.cpp#L1973

    /cc @sipa #4835

  7. promag commented at 8:59 AM on May 28, 2019: member

    @Empact that commit also replaces IsCoinBase() with i > 0. I just think it could be consistent.

  8. practicalswift commented at 7:16 AM on May 29, 2019: contributor

    @promag I think this change makes the code less clear for new contributors who might not be aware of the fact that the first transaction must be a coinbase transaction. If the rationale is performance: the call to IsCoinBase() should be essentially free, no? :-)

  9. mzumsande commented at 12:47 PM on May 29, 2019: member

    For me as a new contributor, the fact that there is currently a mix (lines 2048 and 2051 use i) is more confusing. If we don't want to rely on i>0 in spite of having called CheckBlock() at the beginning of ConnectBlock(), why not use IsCoinBase() consistently (maybe call only once per tx and store in local bool for performance).

  10. promag commented at 1:05 PM on May 29, 2019: member

    PR timeout.

  11. promag closed this on May 29, 2019

  12. promag deleted the branch on May 29, 2019
  13. MarcoFalke 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-22 00:14 UTC

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