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

Keep track of wallet UTXOs and use them for PS balances and rounds calculations #1655

Merged
merged 2 commits into from
Sep 27, 2017

Conversation

UdjinM6
Copy link

@UdjinM6 UdjinM6 commented Sep 25, 2017

For huge wallets with 10K+ txes this cuts down execution time for functions like GetAnonymizableBalance etc. aprox. 10x - from 1-2 sec down to 0.1-0.2
I think this is one of the major issues behind gui hiccups due to cs_main lock used in calculations
(won't solve it completely but feels a bit more responsive with the fix).

@UdjinM6 UdjinM6 added this to the 12.2 milestone Sep 25, 2017
for (auto& pair : mapWallet) {
for(int i = 0; i < pair.second.vout.size(); ++i) {
if (IsMine(pair.second.vout[i]) && !IsSpent(pair.first, i)) {
setWalletUTXO.insert(COutPoint(pair.first, i));

Choose a reason for hiding this comment

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

I'm wondering if this is not better placed in the first if branch of AddToWallet? Would result having setWalletUTXO manipulation in only one place.
https://github.com/dashpay/dash/pull/1655/files#diff-b2bb174788c7409b671c46ccc86034bdR884

Copy link
Author

Choose a reason for hiding this comment

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

Yes, that was the way I implemented it first. But then I thought that (even though it's nice to have all related logic in on place) this approach is kind of suboptimal because when you load some old tx you insert utxo records, and if later you load spending txes for some/all of its outputs you have to remove them. However, if you do this when all txes are already loaded you only have to insert utxos once and there is no remove operation, so this way you skip all useless add/remove (and for huge wallets there could be a lot of them).

Choose a reason for hiding this comment

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

Ah ok, got it. Then I'm fine with this.

@codablock
Copy link

utACK

1 similar comment
@gladcow
Copy link

gladcow commented Sep 27, 2017

utACK

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.

3 participants