Skip to content

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

Merged
UdjinM6 merged 2 commits into
dashpay:v0.12.2.xfrom
UdjinM6:walletutxos
Sep 27, 2017
Merged

Keep track of wallet UTXOs and use them for PS balances and rounds calculations#1655
UdjinM6 merged 2 commits into
dashpay:v0.12.2.xfrom
UdjinM6:walletutxos

Conversation

@UdjinM6

@UdjinM6 UdjinM6 commented Sep 25, 2017

Copy link
Copy Markdown

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
Comment thread src/wallet/wallet.cpp
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));

Copy link
Copy Markdown

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

Copy link
Copy Markdown

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
Copy Markdown

utACK

1 similar comment
@gladcow

gladcow commented Sep 27, 2017

Copy link
Copy Markdown

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