Keep track of wallet UTXOs and use them for PS balances and rounds calculations - #1655
Conversation
58662c2 to
45f9823
Compare
| 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)); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
Ah ok, got it. Then I'm fine with this.
|
utACK |
1 similar comment
|
utACK |
For huge wallets with 10K+ txes this cuts down execution time for functions like
GetAnonymizableBalanceetc. aprox. 10x - from 1-2 sec down to 0.1-0.2I think this is one of the major issues behind gui hiccups due to
cs_mainlock used in calculations(won't solve it completely but feels a bit more responsive with the fix).