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
  1. promag commented at 2:48 pm on July 11, 2018: member
    The new method CWallet::GetBalances computes all balances in one iteration. It also avoids repetitive lock/unlock for each wallet transaction.
  2. fanquake added the label Wallet on Jul 11, 2018
  3. promag commented at 2:50 pm on July 11, 2018: member
    A wallet with 20k transactions, this improves around 30% of the execution time.
  4. 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.
  5. 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 return WalletBalances 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?
  6. 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.

  7. promag force-pushed on Jul 11, 2018
  8. wallet: 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.
    c32f3564db
  9. promag force-pushed on Jul 13, 2018
  10. DrahtBot commented at 11:21 am on July 14, 2018: member
  11. DrahtBot added the label Needs rebase on Jul 14, 2018
  12. martinpgaunt approved
  13. promag commented at 4:02 pm on October 24, 2018: member
    This introduces duplicate code which. Closing for now because I think a different refactor might make sense.
  14. promag closed this on Oct 24, 2018

  15. promag deleted the branch on Oct 24, 2018
  16. laanwj removed the label Needs rebase on Oct 24, 2019
  17. DrahtBot locked this on Dec 16, 2021

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-07-05 22:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me