add CWalletTx::GetImmatureCredit() and use it in CWallet::GetImmatureBalance() #1479

pull Diapolo wants to merge 1 commits into bitcoin:master from Diapolo:wallet_add_GetImmatureCredit changing 2 files +20 −3
  1. Diapolo commented at 6:35 am on June 18, 2012: none
    This harmonizes CWallet::GetImmatureBalance() with CWallet::GetBalance() and CWallet::GetUnconfirmedBalance().
  2. gavinandresen commented at 1:45 pm on June 18, 2012: contributor
    How should this be tested?
  3. sipa commented at 1:56 pm on June 18, 2012: member
    I suppose you could temporarily add an immature_amount to the gettransaction() RPC, and immature_balance to getinfo(), and mine a few blocks on testnet.
  4. Diapolo commented at 1:19 pm on June 20, 2012: none
    I “only” verified this patch with Bitcoin-Qt on testnet, I’m not sure how to test this with bitcoind, as I can’t compile it. Help would be appreciated, as this testing is blocking a merge.
  5. BitcoinPullTester commented at 11:41 pm on August 9, 2012: none
    Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/ed1afd67c1d3f485a9ba3850ba2751e50d897f53 for binaries and test log.
  6. luke-jr commented at 6:56 pm on August 12, 2012: member
    @Diapolo Those builds from @BitcoinPullTester should help you out
  7. Diapolo commented at 8:44 pm on August 13, 2012: none
    @luke-jr How does this help? You mean using the Qt version from jenkins and using it on testnet?
  8. Diapolo commented at 8:33 am on August 25, 2012: none

    Guys, I setup bitcoind and can use it to pass RPC commands, but I simply don’t know how you want me to test the function there, as GetImmatureBalance() seems to be only used by Qt?

    I could for sure add obj.push_back(Pair("walletversion", pwalletMain->GetImmatureBalance())); to RPC getinfo, but as I can’t compile bitcoind I would rely on @BitcoinPullTester to create a bitcoind.exe for me and need to revert that change before this would be considered mergeable.

  9. sipa commented at 11:38 am on August 25, 2012: member
    GetImmatureBalance looks correct from reading it, and it’s only used within the Qt code. I’m sure we can use it in RPC code as well, but let’s do that later.
  10. Diapolo commented at 0:18 am on August 26, 2012: none
    @sipa I didn’t want to push or create a usage scenario for RPC, I just wanted to say I dunno how to further test this code :). As I said in Qt it does the job and asked if it will get accepted that way or what I can do now.
  11. sipa commented at 0:19 am on August 26, 2012: member
    ACK on the changes to core; I didn’t test the UI changes.
  12. BitcoinPullTester commented at 1:07 pm on August 26, 2012: none
    Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/dfdd4dac8291b55fd96feea3b4545a0a5389e86b for binaries and test log.
  13. add CWalletTx::GetImmatureCredit() and use it in CWallet::GetImmatureBalance() 966a0e8cc9
  14. Diapolo commented at 6:58 am on November 13, 2012: none
    Rebased!
  15. in src/wallet.cpp: in 966a0e8cc9
    925@@ -926,9 +926,8 @@ int64 CWallet::GetImmatureBalance() const
    926         LOCK(cs_wallet);
    927         for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)
    928         {
    929-            const CWalletTx& pcoin = (*it).second;
    930-            if (pcoin.IsCoinBase() && pcoin.GetBlocksToMaturity() > 0 && pcoin.IsInMainChain())
    931-                nTotal += GetCredit(pcoin);
    932+            const CWalletTx* pcoin = &(*it).second;
    


    laanwj commented at 7:10 am on November 13, 2012:
    Why change this to a pointer instead of a reference (&)? IMO &(*it).second; is slightly more ugly code, and in C++ it’s generally advised to use references instead of pointers where possible (for type safety etc).

    Diapolo commented at 7:23 am on November 13, 2012:
    Same as below, I wanted this to be similar to the other functions, perhaps it would be a good idea to update all these to be more C++ style then? But I’m not sure if core devs would ACK such a change on that code-part?

    laanwj commented at 7:31 am on November 13, 2012:
    Satoshi is a very bad person to learn C++ style from :poodle: If you want an example of well-structured, readable C++ I can recommend reading source from LLVM. And I’m not sure either, it doesn’t warrant changing all the functions I guess… maybe just leave it like this then.
  16. in src/wallet.h: in 966a0e8cc9
    566@@ -563,6 +567,20 @@ class CWalletTx : public CMerkleTx
    567         return nCreditCached;
    568     }
    569 
    570+    int64 GetImmatureCredit(bool fUseCache=true) const
    571+    {
    


    laanwj commented at 7:17 am on November 13, 2012:
    ACK (I wonder why this implementation is in the .h, not the .cpp, but I suppose you simply followed the example of GetAvailableCredit)

    Diapolo commented at 7:21 am on November 13, 2012:
    Indeed, I just used what was there. Sometimes I have not that wide view/knowlegde you have in the area of coding :).
  17. laanwj referenced this in commit f2b12807d0 on Nov 13, 2012
  18. laanwj merged this on Nov 13, 2012
  19. laanwj closed this on Nov 13, 2012

  20. laudney referenced this in commit 80dc8604fe on Mar 19, 2014
  21. suprnurd referenced this in commit fc406f2d82 on Dec 5, 2017
  22. lateminer referenced this in commit 3de9bd56af on Jan 22, 2019
  23. lateminer referenced this in commit c9c618e365 on May 6, 2020
  24. DrahtBot locked this on Sep 8, 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-11-17 18:12 UTC

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