17 int64_t _nTime,
double _dPriority,
18 unsigned int _nHeight):
19 tx(_tx), nFee(_nFee), nTime(_nTime), dPriority(_dPriority), nHeight(_nHeight)
33 double deltaPriority = ((double)(currentHeight-
nHeight)*nValueIn)/
nTxSize;
34 double dResult =
dPriority + deltaPriority;
50 std::map<COutPoint, CInPoint>::iterator it =
mapNextTx.lower_bound(
COutPoint(hashTx, 0));
53 while (it !=
mapNextTx.end() && it->first.hash == hashTx) {
54 coins.
Spend(it->first.n);
81 for (
unsigned int i = 0; i < tx.
vin.size(); i++)
96 for (
unsigned int i = 0; i < tx.
vout.size(); i++) {
100 remove(*it->second.ptx, removed,
true);
103 if (
mapTx.count(hash))
105 removed.push_front(tx);
106 BOOST_FOREACH(
const CTxIn& txin, tx.
vin)
117 list<CTransaction> result;
119 BOOST_FOREACH(
const CTxIn &txin, tx.
vin) {
123 if (txConflict != tx)
125 remove(txConflict, removed,
true);
144 LogPrint(
"mempool",
"Checking mempool with %u transactions and %u inputs\n", (
unsigned int)
mapTx.size(), (
unsigned int)
mapNextTx.size());
147 for (std::map<uint256, CTxMemPoolEntry>::const_iterator it =
mapTx.begin(); it !=
mapTx.end(); it++) {
150 BOOST_FOREACH(
const CTxIn &txin, tx.
vin) {
152 std::map<uint256, CTxMemPoolEntry>::const_iterator it2 =
mapTx.find(txin.
prevout.
hash);
153 if (it2 !=
mapTx.end()) {
161 std::map<COutPoint, CInPoint>::const_iterator it3 =
mapNextTx.find(txin.
prevout);
163 assert(it3->second.ptx == &tx);
164 assert(it3->second.n == i);
168 for (std::map<COutPoint, CInPoint>::const_iterator it =
mapNextTx.begin(); it !=
mapNextTx.end(); it++) {
169 uint256 hash = it->second.ptx->GetHash();
170 map<uint256, CTxMemPoolEntry>::const_iterator it2 =
mapTx.find(hash);
172 assert(it2 !=
mapTx.end());
173 assert(&tx == it->second.ptx);
174 assert(tx.
vin.size() > it->second.n);
175 assert(it->first == it->second.ptx->vin[it->second.n].prevout);
184 vtxid.reserve(
mapTx.size());
185 for (map<uint256, CTxMemPoolEntry>::iterator mi =
mapTx.begin(); mi !=
mapTx.end(); ++mi)
186 vtxid.push_back((*mi).first);
192 map<uint256, CTxMemPoolEntry>::const_iterator i =
mapTx.find(hash);
193 if (i ==
mapTx.end())
return false;
194 result = i->second.GetTx();
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.
static int LogPrint(const char *category, const char *format)
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)
static const int PROTOCOL_VERSION
bool exists(uint256 hash)
An inpoint - a combination of a transaction and an index n into its vin.
static const unsigned int MEMPOOL_HEIGHT
Fake height value used in CCoins to signify they are only in the memory pool (since 0...
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.