LCOV - code coverage report
Current view: top level - src/policy - rbf.cpp (source / functions) Hit Total Coverage
Test: total_coverage.info Lines: 17 19 89.5 %
Date: 2020-09-26 01:30:44 Functions: 1 2 50.0 %

          Line data    Source code
       1             : // Copyright (c) 2016-2019 The Bitcoin Core developers
       2             : // Distributed under the MIT software license, see the accompanying
       3             : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
       4             : 
       5             : #include <policy/rbf.h>
       6             : #include <util/rbf.h>
       7             : 
       8       53906 : RBFTransactionState IsRBFOptIn(const CTransaction& tx, const CTxMemPool& pool)
       9             : {
      10       53906 :     AssertLockHeld(pool.cs);
      11             : 
      12       53906 :     CTxMemPool::setEntries setAncestors;
      13             : 
      14             :     // First check the transaction itself.
      15       53906 :     if (SignalsOptInRBF(tx)) {
      16         115 :         return RBFTransactionState::REPLACEABLE_BIP125;
      17             :     }
      18             : 
      19             :     // If this transaction is not in our mempool, then we can't be sure
      20             :     // we will know about all its inputs.
      21       53791 :     if (!pool.exists(tx.GetHash())) {
      22         228 :         return RBFTransactionState::UNKNOWN;
      23             :     }
      24             : 
      25             :     // If all the inputs have nSequence >= maxint-1, it still might be
      26             :     // signaled for RBF if any unconfirmed parents have signaled.
      27       53563 :     uint64_t noLimit = std::numeric_limits<uint64_t>::max();
      28       53563 :     std::string dummy;
      29       53563 :     CTxMemPoolEntry entry = *pool.mapTx.find(tx.GetHash());
      30       53563 :     pool.CalculateMemPoolAncestors(entry, setAncestors, noLimit, noLimit, noLimit, noLimit, dummy, false);
      31             : 
      32     2054108 :     for (CTxMemPool::txiter it : setAncestors) {
      33     2000545 :         if (SignalsOptInRBF(it->GetTx())) {
      34           3 :             return RBFTransactionState::REPLACEABLE_BIP125;
      35             :         }
      36     2000545 :     }
      37       53560 :     return RBFTransactionState::FINAL;
      38       53906 : }
      39             : 
      40           0 : RBFTransactionState IsRBFOptInEmptyMempool(const CTransaction& tx)
      41             : {
      42             :     // If we don't have a local mempool we can only check the transaction itself.
      43           0 :     return SignalsOptInRBF(tx) ? RBFTransactionState::REPLACEABLE_BIP125 : RBFTransactionState::UNKNOWN;
      44             : }

Generated by: LCOV version 1.15