Dash Core  0.12.2.1
P2P Digital Currency
rbf.cpp
Go to the documentation of this file.
1 // Copyright (c) 2016 The Bitcoin 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 
8 {
9  BOOST_FOREACH(const CTxIn &txin, tx.vin) {
10  if (txin.nSequence < std::numeric_limits<unsigned int>::max()-1) {
11  return true;
12  }
13  }
14  return false;
15 }
16 
17 bool IsRBFOptIn(const CTxMemPoolEntry &entry, CTxMemPool &pool)
18 {
19  AssertLockHeld(pool.cs);
20 
21  CTxMemPool::setEntries setAncestors;
22 
23  // First check the transaction itself.
24  if (SignalsOptInRBF(entry.GetTx())) {
25  return true;
26  }
27 
28  // If this transaction is not in our mempool, then we can't be sure
29  // we will know about all its inputs.
30  if (!pool.exists(entry.GetTx().GetHash())) {
31  throw std::runtime_error("Cannot determine RBF opt-in signal for non-mempool transaction\n");
32  }
33 
34  // If all the inputs have nSequence >= maxint-1, it still might be
35  // signaled for RBF if any unconfirmed parents have signaled.
36  uint64_t noLimit = std::numeric_limits<uint64_t>::max();
37  std::string dummy;
38  pool.CalculateMemPoolAncestors(entry, setAncestors, noLimit, noLimit, noLimit, noLimit, dummy, false);
39 
40  BOOST_FOREACH(CTxMemPool::txiter it, setAncestors) {
41  if (SignalsOptInRBF(it->GetTx())) {
42  return true;
43  }
44  }
45  return false;
46 }
uint32_t nSequence
Definition: transaction.h:63
bool CalculateMemPoolAncestors(const CTxMemPoolEntry &entry, setEntries &setAncestors, uint64_t limitAncestorCount, uint64_t limitAncestorSize, uint64_t limitDescendantCount, uint64_t limitDescendantSize, std::string &errString, bool fSearchForParents=true)
Definition: txmempool.cpp:183
bool exists(uint256 hash) const
Definition: txmempool.h:563
#define AssertLockHeld(cs)
Definition: sync.h:96
CCriticalSection cs
Definition: txmempool.h:402
indexed_transaction_set::nth_index< 0 >::type::iterator txiter
Definition: txmempool.h:404
const CTransaction & GetTx() const
Definition: txmempool.h:110
bool IsRBFOptIn(const CTxMemPoolEntry &entry, CTxMemPool &pool)
Definition: rbf.cpp:17
std::set< txiter, CompareIteratorByHash > setEntries
Definition: txmempool.h:410
const std::vector< CTxIn > vin
Definition: transaction.h:233
bool SignalsOptInRBF(const CTransaction &tx)
Definition: rbf.cpp:7
const uint256 & GetHash() const
Definition: transaction.h:262