Raven Core  3.0.0
P2P Digital Currency
rbf.cpp
Go to the documentation of this file.
1 // Copyright (c) 2016 The Bitcoin Core developers
2 // Copyright (c) 2017-2019 The Raven Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #include "policy/rbf.h"
7 
9 {
10  for (const CTxIn &txin : tx.vin) {
11  if (txin.nSequence < std::numeric_limits<unsigned int>::max()-1) {
12  return true;
13  }
14  }
15  return false;
16 }
17 
19 {
20  AssertLockHeld(pool.cs);
21 
22  CTxMemPool::setEntries setAncestors;
23 
24  // First check the transaction itself.
25  if (SignalsOptInRBF(tx)) {
27  }
28 
29  // If this transaction is not in our mempool, then we can't be sure
30  // we will know about all its inputs.
31  if (!pool.exists(tx.GetHash())) {
33  }
34 
35  // If all the inputs have nSequence >= maxint-1, it still might be
36  // signaled for RBF if any unconfirmed parents have signaled.
37  uint64_t noLimit = std::numeric_limits<uint64_t>::max();
38  std::string dummy;
39  CTxMemPoolEntry entry = *pool.mapTx.find(tx.GetHash());
40  pool.CalculateMemPoolAncestors(entry, setAncestors, noLimit, noLimit, noLimit, noLimit, dummy, false);
41 
42  for (CTxMemPool::txiter it : setAncestors) {
43  if (SignalsOptInRBF(it->GetTx())) {
45  }
46  }
48 }
RBFTransactionState
Definition: rbf.h:13
std::set< txiter, CompareIteratorByHash > setEntries
Definition: txmempool.h:499
const std::vector< CTxIn > vin
Definition: transaction.h:287
CTxMemPoolEntry stores data about the corresponding transaction, as well as data about all in-mempool...
Definition: txmempool.h:68
indexed_transaction_set mapTx
Definition: txmempool.h:469
#define AssertLockHeld(cs)
Definition: sync.h:86
An input of a transaction.
Definition: transaction.h:67
const uint256 & GetHash() const
Definition: transaction.h:320
bool exists(uint256 hash) const
Definition: txmempool.h:660
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) const
Try to calculate all in-mempool ancestors of entry.
Definition: txmempool.cpp:154
indexed_transaction_set::nth_index< 0 >::type::iterator txiter
Definition: txmempool.h:491
CCriticalSection cs
Definition: txmempool.h:468
RBFTransactionState IsRBFOptIn(const CTransaction &tx, CTxMemPool &pool)
Definition: rbf.cpp:18
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
Definition: txmempool.h:416
uint32_t nSequence
Definition: transaction.h:72
bool SignalsOptInRBF(const CTransaction &tx)
Definition: rbf.cpp:8
The basic transaction that is broadcasted on the network and contained in blocks. ...
Definition: transaction.h:270