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

Optimize mining checks for various stake transactions #83

Merged
merged 1 commit into from Mar 4, 2016

Conversation

cjepson
Copy link
Contributor

@cjepson cjepson commented Mar 4, 2016

Many of the checks for the type of stake transaction in the main sorting
loop for mempool transactions of NewBlockTemplate were redundant. Now the
cached data for the transaction type is used instead. An expensive lookup
for a transaction cache was also moved for efficiency.


if isSSGen, _ := stake.IsSSGen(tx); isSSGen {
txType := txDesc.Type
isSSGen := txType == stake.TxTypeSSGen
Copy link
Member

Choose a reason for hiding this comment

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

I know this is legal go, but I kind of think lines like that are very hard to read when going through it quickly. Is there any clearer way to do it?

@jcvernaleo
Copy link
Member

Other than the comments above this looks fine. Someone who mines needs to test for real though.

Many of the checks for the type of stake transaction in the main sorting
loop for mempool transactions of NewBlockTemplate were redundant. Now the
cached data for the transaction type is used instead. An expensive lookup
for a transaction cache was also moved for efficiency.
@cjepson
Copy link
Contributor Author

cjepson commented Mar 4, 2016

I cleaned up the extra declaration for the first case, but I think it's still as clean as it gets in the second case. The alternative is declaring all the vars and then doing a switch on the txType, which I think is ugly, or just not using a bool for them altogether and using equates to constants, which I think is ugly too.

@alexlyp
Copy link
Member

alexlyp commented Mar 4, 2016

ntACK

@jcvernaleo
Copy link
Member

@cjepson fair enough about the second case, it is choosing between ugly and ugly. So just waiting for the tACK and good to go.

@jolan
Copy link
Contributor

jolan commented Mar 4, 2016

Mined 70 blocks with this, nothing out of the ordinary noticed.

tACK

@jcvernaleo jcvernaleo merged commit db3e406 into decred:master Mar 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants