CWallet::GetBalances
computes all balances in one iteration.
It also avoids repetitive lock/unlock for each wallet transaction.
wallet: Add GetBalances to calculate all balances #13637
pull promag wants to merge 1 commits into bitcoin:master from promag:2018-06-wallet-getbalance changing 3 files +42 −9-
promag commented at 2:48 pm on July 11, 2018: memberThe new method
-
fanquake added the label Wallet on Jul 11, 2018
-
promag commented at 2:50 pm on July 11, 2018: memberA wallet with 20k transactions, this improves around 30% of the execution time.
-
in src/wallet/wallet.cpp:2117 in 96fffac4ae outdated
2113@@ -2114,6 +2114,44 @@ void CWallet::ResendWalletTransactions(int64_t nBestBlockTime, CConnman* connman 2114 * @{ 2115 */ 2116 2117+// void CWalletTx::AddBalances(CAmount& balance, CAmount& unconfirmed_balance, CAmount& immature_balance, bool& have_watch_only, CAmount& watch_only_balance, CAmount& unconfirmed_watch_only_balance, CAmount& immature_watch_only_balance) const
MarcoFalke commented at 2:50 pm on July 11, 2018::eyes:
promag commented at 3:05 pm on July 11, 2018:Heh
promag commented at 3:08 pm on July 11, 2018:BTW this is another experiment where many computations are deduped per wallet tx. Still WIP.in src/wallet/wallet.h:945 in 96fffac4ae outdated
941@@ -942,6 +942,7 @@ class CWallet final : public CCryptoKeyStore, public CValidationInterface 942 void ResendWalletTransactions(int64_t nBestBlockTime, CConnman* connman) override; 943 // ResendWalletTransactionsBefore may only be called if fBroadcastTransactions! 944 std::vector<uint256> ResendWalletTransactionsBefore(int64_t nTime, CConnman* connman); 945+ void GetBalances(CAmount& balance, CAmount& unconfirmed_balance, CAmount& immature_balance, bool& have_watch_only, CAmount& watch_only_balance, CAmount& unconfirmed_watch_only_balance, CAmount& immature_watch_only_balance) const;
MarcoFalke commented at 2:54 pm on July 11, 2018:Could returnWalletBalances
instead to avoid having to pass a ton of args?
promag commented at 3:06 pm on July 11, 2018:Not sure, wouldn’t it add cyclic dependency?DrahtBot commented at 3:14 pm on July 11, 2018: member- #13566 (Fix get balance by jnewbery)
- #13083 (Add compile time checking for cs_main runtime locking assertions by practicalswift)
- #11020 ([wallet] getbalance: Add option to include non-mempool UTXOs by kallewoof)
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
promag force-pushed on Jul 11, 2018wallet: Add GetBalances to calculate all balances
The new method `CWallet::GetBalances` computes all balances in one iteration. It also avoids repetitive lock/unlock for each wallet transaction.
promag force-pushed on Jul 13, 2018DrahtBot commented at 11:21 am on July 14, 2018: memberDrahtBot added the label Needs rebase on Jul 14, 2018martinpgaunt approvedpromag commented at 4:02 pm on October 24, 2018: memberThis introduces duplicate code which. Closing for now because I think a different refactor might make sense.promag closed this on Oct 24, 2018
promag deleted the branch on Oct 24, 2018laanwj removed the label Needs rebase on Oct 24, 2019DrahtBot locked this on Dec 16, 2021
promag MarcoFalke DrahtBot martinpgauntLabels
Wallet
github-metadata-mirror
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-17 09:12 UTC
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-17 09:12 UTC
This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me
More mirrored repositories can be found on mirror.b10c.me