14 nHeight = MEMPOOL_HEIGHT;
18 int64_t _nTime,
double _dPriority,
19 unsigned int _nHeight):
20 tx(_tx), nFee(_nFee), nTime(_nTime), dPriority(_dPriority), nHeight(_nHeight)
34 double deltaPriority = ((double)(currentHeight-
nHeight)*nValueIn)/
nTxSize;
35 double dResult =
dPriority + deltaPriority;
51 std::map<COutPoint, CInPoint>::iterator it =
mapNextTx.lower_bound(
COutPoint(hashTx, 0));
54 while (it !=
mapNextTx.end() && it->first.hash == hashTx) {
55 coins.
Spend(it->first.n);
82 for (
unsigned int i = 0; i < tx.
vin.size(); i++)
97 for (
unsigned int i = 0; i < tx.
vout.size(); i++) {
101 remove(*it->second.ptx, removed,
true);
104 if (
mapTx.count(hash))
106 removed.push_front(tx);
107 BOOST_FOREACH(
const CTxIn& txin, tx.
vin)
118 list<CTransaction> result;
120 BOOST_FOREACH(
const CTxIn &txin, tx.
vin) {
124 if (txConflict != tx)
126 remove(txConflict, removed,
true);
145 LogPrint(
"mempool",
"Checking mempool with %u transactions and %u inputs\n", (
unsigned int)
mapTx.size(), (
unsigned int)
mapNextTx.size());
148 for (std::map<uint256, CTxMemPoolEntry>::const_iterator it =
mapTx.begin(); it !=
mapTx.end(); it++) {
151 BOOST_FOREACH(
const CTxIn &txin, tx.
vin) {
153 std::map<uint256, CTxMemPoolEntry>::const_iterator it2 =
mapTx.find(txin.
prevout.
hash);
154 if (it2 !=
mapTx.end()) {
162 std::map<COutPoint, CInPoint>::const_iterator it3 =
mapNextTx.find(txin.
prevout);
164 assert(it3->second.ptx == &tx);
165 assert(it3->second.n == i);
169 for (std::map<COutPoint, CInPoint>::const_iterator it =
mapNextTx.begin(); it !=
mapNextTx.end(); it++) {
170 uint256 hash = it->second.ptx->GetHash();
171 map<uint256, CTxMemPoolEntry>::const_iterator it2 =
mapTx.find(hash);
173 assert(it2 !=
mapTx.end());
174 assert(&tx == it->second.ptx);
175 assert(tx.
vin.size() > it->second.n);
176 assert(it->first == it->second.ptx->vin[it->second.n].prevout);
185 vtxid.reserve(
mapTx.size());
186 for (map<uint256, CTxMemPoolEntry>::iterator mi =
mapTx.begin(); mi !=
mapTx.end(); ++mi)
187 vtxid.push_back((*mi).first);
193 map<uint256, CTxMemPoolEntry>::const_iterator i =
mapTx.find(hash);
194 if (i ==
mapTx.end())
return false;
195 result = i->second.GetTx();
206 coins =
CCoins(tx, MEMPOOL_HEIGHT);
int64_t GetValueOut() const
void check(CCoinsViewCache *pcoins) const
bool HaveCoins(const uint256 &txid)
bool lookup(uint256 hash, CTransaction &result) const
std::map< COutPoint, CInPoint > mapNextTx
CCoinsViewMemPool(CCoinsView &baseIn, CTxMemPool &mempoolIn)
void queryHashes(std::vector< uint256 > &vtxid)
pruned version of CTransaction: only retains metadata and unspent transaction outputs ...
bool GetCoins(const uint256 &txid, CCoins &coins)
bool IsAvailable(unsigned int nPos) const
unsigned int GetTransactionsUpdated() const
unsigned int GetSerializeSize(char a, int, int=0)
Abstract view on the open txout dataset.
An input of a transaction.
virtual bool GetCoins(const uint256 &txid, CCoins &coins)
std::vector< CTxOut > vout
bool GetCoins(const uint256 &txid, CCoins &coins)
double GetPriority(unsigned int currentHeight) const
virtual bool HaveCoins(const uint256 &txid)
std::map< uint256, CTxMemPoolEntry > mapTx
unsigned int nTransactionsUpdated
An outpoint - a combination of a transaction hash and an index n into its vout.
void AddTransactionsUpdated(unsigned int n)
void remove(const CTransaction &tx, std::list< CTransaction > &removed, bool fRecursive=false)
void removeConflicts(const CTransaction &tx, std::list< CTransaction > &removed)
void pruneSpent(const uint256 &hash, CCoins &coins)
bool Spend(const COutPoint &out, CTxInUndo &undo)
bool addUnchecked(const uint256 &hash, const CTxMemPoolEntry &entry)
bool exists(uint256 hash)
An inpoint - a combination of a transaction and an index n into its vin.
The basic transaction that is broadcasted on the network and contained in blocks. ...
CCoinsView backed by another CCoinsView.
CCoinsView that adds a memory cache for transactions to another CCoinsView.