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

[wallet] Extra GetTransaction call in stakeable coins selection flow removed. #1850

Merged

Conversation

furszy
Copy link

@furszy furszy commented Sep 11, 2020

Essentially, this work is removing an unneeded GetTransaction call from CPivStake::GetIndexFrom for every stakeable output during each cycle of the staking process.
As GetTransaction is a direct access to disk (txindex), this means faster staking.

Future work, the methods StakeableCoins and AvailableCoins can be abstracted even more. They are sharing almost the same code with an specific distinction that makes this change possible without introducing an extra blockIndex set into AvailableCoins.

@furszy furszy self-assigned this Sep 11, 2020
@furszy furszy changed the title WIP [wallet] Extra GetTransaction call in stakeable coins selection flow removed. [wallet] Extra GetTransaction call in stakeable coins selection flow removed. Sep 16, 2020
@random-zebra random-zebra added Block Generation Mining/Staking related issues Refactoring Wallet labels Sep 22, 2020
@random-zebra random-zebra added this to the 5.0.0 milestone Sep 22, 2020
Copy link

@random-zebra random-zebra left a comment

Choose a reason for hiding this comment

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

This needs a rebase. Otherwise looking pretty good. Just a few points.

src/stakeinput.h Outdated Show resolved Hide resolved
src/stakeinput.cpp Show resolved Hide resolved
@furszy furszy force-pushed the 2020_stakeInput_less_GetTransaction_usage branch from 920f17c to f61e71f Compare October 3, 2020 16:26
@furszy
Copy link
Author

furszy commented Oct 3, 2020

Rebased on top of master.
Plus, added a commit making the CPivStake class immutable. Solving feedback comments.

@furszy furszy force-pushed the 2020_stakeInput_less_GetTransaction_usage branch from f61e71f to 5260c12 Compare October 3, 2020 16:41
@furszy furszy force-pushed the 2020_stakeInput_less_GetTransaction_usage branch from 5260c12 to 06bae43 Compare October 5, 2020 14:15
@furszy
Copy link
Author

furszy commented Oct 5, 2020

rebased on master.

Copy link

@random-zebra random-zebra left a comment

Choose a reason for hiding this comment

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

Nice. Much better with CPivStake immutable.
Just few notes.

src/kernel.cpp Outdated Show resolved Hide resolved
src/stakeinput.cpp Outdated Show resolved Hide resolved
src/stakeinput.cpp Outdated Show resolved Hide resolved
src/stakeinput.h Outdated Show resolved Hide resolved
src/stakeinput.h Outdated Show resolved Hide resolved
@furszy furszy force-pushed the 2020_stakeInput_less_GetTransaction_usage branch from 06bae43 to 5935497 Compare October 5, 2020 18:10
@furszy
Copy link
Author

furszy commented Oct 5, 2020

updated per feedback.

Copy link

@random-zebra random-zebra left a comment

Choose a reason for hiding this comment

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

As per feedback inline, I think InitFromTxIn shouldn't be used for piv stakes (it isn't intended to "check if the object is initialized" anyway, it was meant for setting things)... you could just override it to false in the header.
Similarly GetTxOutFrom could be easily changed in the base class, and overriden to return an empty object, for zpiv stakes, where it's not used.

But these are just styling changes, so if you're not happy making them, I'm fine with the PR as is. Tested ACK 5935497

@furszy
Copy link
Author

furszy commented Oct 5, 2020

Hey, was answering and didn't see this last comment. I'm good with almost every comment, i thought on some of them as well but.. this PR is already fulfilling its main goal of removing the GetTransaction function call. Better to leave them for another refactoring round.

Copy link
Collaborator

@Fuzzbawls Fuzzbawls left a comment

Choose a reason for hiding this comment

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

ACK 5935497

@furszy furszy merged commit 9520ee3 into PIVX-Project:master Oct 8, 2020
@furszy furszy deleted the 2020_stakeInput_less_GetTransaction_usage branch November 29, 2022 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Block Generation Mining/Staking related issues Refactoring Wallet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants