Skip to content
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

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

Closed
wants to merge 1 commit into from

Conversation

promag
Copy link
Member

@promag promag commented May 27, 2019

Replaces CTransaction::IsCoinbase() with the same cheap check as:

if (i > 0) {

@promag
Copy link
Member Author

promag commented May 27, 2019

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

@Empact
Copy link
Member

Empact commented May 27, 2019

-0 IMO better to rely on the definition in IsCoinBase. I think the line you cite may be for coherence with

blockundo.vtxundo.reserve(block.vtx.size() - 1);

/cc @sipa #4835

@promag
Copy link
Member Author

promag commented May 28, 2019

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

@practicalswift
Copy link
Contributor

practicalswift commented May 29, 2019

@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? :-)

@mzumsande
Copy link
Contributor

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).

@promag
Copy link
Member Author

promag commented May 29, 2019

PR timeout.

@promag promag closed this May 29, 2019
@promag promag deleted the 2015-05-avoid-iscoinbase branch May 29, 2019 13:05
@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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants