Remove unnecessary calls to CheckFinalTx #9141

pull jonasschnelli wants to merge 1 commits into bitcoin:master from jonasschnelli:2016/11/istrusted changing 1 files +1 −1
  1. jonasschnelli commented at 9:10 AM on November 12, 2016: contributor

    Tiny optimization. CheckFinalTx() gets always called in CWalletTx::IsTrusted(). Calling it together with IsTrusted() result in calling it twice.

    CheckFinalTx() get's executed under cs_main (where it calls stuff like tips GetMedianTimePast(), `GetAdjustedTime().

  2. jonasschnelli added the label Wallet on Nov 12, 2016
  3. MarcoFalke commented at 11:18 AM on November 12, 2016: member

    utACK 1484993f691b0913d03154e2fdd0687736c65052

  4. Remove unnecessary calls to CheckFinalTx 4512550fa0
  5. in src/wallet/wallet.cpp:None in 1484993f69 outdated
    1938 | @@ -1939,9 +1939,6 @@ void CWallet::AvailableCoins(vector<COutput>& vCoins, bool fOnlyConfirmed, const
    1939 |              const uint256& wtxid = it->first;
    1940 |              const CWalletTx* pcoin = &(*it).second;
    1941 |  
    1942 | -            if (!CheckFinalTx(*pcoin))
    1943 | -                continue;
    1944 | -
    1945 |              if (fOnlyConfirmed && !pcoin->IsTrusted())
    


    paveljanik commented at 12:34 PM on November 12, 2016:

    If fOnlyConfirmed is false, IsTrusted() is not executed at all. Is this OK?


    jonasschnelli commented at 12:52 PM on November 12, 2016:

    Yes. Your right, was deluded by the OR further down. I just removed that part.

  6. jonasschnelli force-pushed on Nov 12, 2016
  7. morcos commented at 6:46 PM on November 12, 2016: member

    When I was adding the logic for sequence locks we decided it was not worth calculating those for wallet txs, primarily because it was near impossible to have a non-final transaction in your wallet (since you would never have accepted it to your mempool). Perhaps out of scope for this PR, but I think we should consider whether we want to support any notion of finality in the wallet at all. These existing CheckFinalTx checks are cheaper but still contribute to complication. Maybe we can just remove them all?

    Or if we do want to support them, then maybe there is an efficient and general way we can support finality checks for both types of locks. Such as caching the time/height that the tx will be final and in the case of sequence locks, the hash that needs to remain on the main chain for that calculation to still be valid.

  8. mrbandrews commented at 7:02 PM on November 17, 2016: contributor

    Code review ACK 4512550

  9. laanwj commented at 6:24 AM on November 23, 2016: member

    we decided it was not worth calculating those for wallet txs, primarily because it was near impossible to have a non-final transaction in your wallet

    This is true at the moment. Although non-final handling may make sense when the GUI, some day, allows producing transactions that are not final yet. But maybe they could just be flagged some way to keep them from being considered for balance computation until they're actually on the network. So I tend to agree.

  10. laanwj merged this on Nov 23, 2016
  11. laanwj closed this on Nov 23, 2016

  12. laanwj referenced this in commit 5ea5e0401c on Nov 23, 2016
  13. codablock referenced this in commit d757c895b9 on Jan 15, 2018
  14. andvgal referenced this in commit fa846fb747 on Jan 6, 2019
  15. CryptoCentric referenced this in commit c4e6b644f0 on Feb 24, 2019
  16. MarcoFalke 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: 2026-04-21 15:15 UTC

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