// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2014 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
-// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+// file COPYING or https://www.opensource.org/licenses/mit-license.php .
#include "txmempool.h"
#include "timedata.h"
#include "util.h"
#include "utilmoneystr.h"
+#include "validationinterface.h"
#include "version.h"
+#include "pbaas/pbaas.h"
#define _COINBASE_MATURITY 100
using namespace std;
CTxMemPoolEntry::CTxMemPoolEntry():
nFee(0), nTxSize(0), nModSize(0), nUsageSize(0), nTime(0), dPriority(0.0),
- hadNoDependencies(false), spendsCoinbase(false)
+ hadNoDependencies(false), spendsCoinbase(false), hasReserve(false)
{
nHeight = MEMPOOL_HEIGHT;
}
CTxMemPoolEntry::CTxMemPoolEntry(const CTransaction& _tx, const CAmount& _nFee,
int64_t _nTime, double _dPriority,
unsigned int _nHeight, bool poolHasNoInputsOf,
- bool _spendsCoinbase, uint32_t _nBranchId):
+ bool _spendsCoinbase, uint32_t _nBranchId, bool hasreserve):
tx(_tx), nFee(_nFee), nTime(_nTime), dPriority(_dPriority), nHeight(_nHeight),
- hadNoDependencies(poolHasNoInputsOf),
+ hadNoDependencies(poolHasNoInputsOf), hasReserve(hasreserve),
spendsCoinbase(_spendsCoinbase), nBranchId(_nBranchId)
{
nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION);
CTxMemPoolEntry::GetPriority(unsigned int currentHeight) const
{
CAmount nValueIn = tx.GetValueOut()+nFee;
+ CCurrencyState currencyState;
+ unsigned int lastHeight = currentHeight < 1 ? 0 : currentHeight - 1;
+ if (hasReserve && (currencyState = ConnectedChains.GetCurrencyState(currentHeight - 1)).IsValid())
+ {
+ nValueIn += currencyState.ReserveToNative(tx.GetReserveValueOut());
+ }
double deltaPriority = ((double)(currentHeight-nHeight)*nValueIn)/nModSize;
double dResult = dPriority + deltaPriority;
return dResult;
LOCK(cs);
mapTx.insert(entry);
const CTransaction& tx = mapTx.find(hash)->GetTx();
+ mapRecentlyAddedTx[tx.GetHash()] = &tx;
+ nRecentlyAddedSequence += 1;
if (!tx.IsCoinImport()) {
for (unsigned int i = 0; i < tx.vin.size(); i++)
mapNextTx[tx.vin[i].prevout] = CInPoint(&tx, i);
}
- BOOST_FOREACH(const JSDescription &joinsplit, tx.vjoinsplit) {
+ BOOST_FOREACH(const JSDescription &joinsplit, tx.vJoinSplit) {
BOOST_FOREACH(const uint256 &nf, joinsplit.nullifiers) {
- mapNullifiers[nf] = &tx;
+ mapSproutNullifiers[nf] = &tx;
}
}
+ for (const SpendDescription &spendDescription : tx.vShieldedSpend) {
+ mapSaplingNullifiers[spendDescription.nullifier] = &tx;
+ }
nTransactionsUpdated++;
totalTxSize += entry.GetTxSize();
cachedInnerUsage += entry.DynamicMemoryUsage();
std::vector<CMempoolAddressDeltaKey> inserted;
uint256 txhash = tx.GetHash();
- for (unsigned int j = 0; j < tx.vin.size(); j++) {
- const CTxIn input = tx.vin[j];
- const CTxOut &prevout = view.GetOutputFor(input);
- if (prevout.scriptPubKey.IsPayToScriptHash()) {
- vector<unsigned char> hashBytes(prevout.scriptPubKey.begin()+2, prevout.scriptPubKey.begin()+22);
- CMempoolAddressDeltaKey key(2, uint160(hashBytes), txhash, j, 1);
- CMempoolAddressDelta delta(entry.GetTime(), prevout.nValue * -1, input.prevout.hash, input.prevout.n);
- mapAddress.insert(make_pair(key, delta));
- inserted.push_back(key);
- } else if (prevout.scriptPubKey.IsPayToPublicKeyHash()) {
- vector<unsigned char> hashBytes(prevout.scriptPubKey.begin()+1, prevout.scriptPubKey.begin()+34);
- CMempoolAddressDeltaKey key(1, uint160(hashBytes), txhash, j, 1);
+ if (!tx.IsCoinBase())
+ {
+ for (unsigned int j = 0; j < tx.vin.size(); j++) {
+ const CTxIn input = tx.vin[j];
+ const CTxOut &prevout = view.GetOutputFor(input);
+ CScript::ScriptType type = prevout.scriptPubKey.GetType();
+ if (type == CScript::UNKNOWN)
+ continue;
+ CMempoolAddressDeltaKey key(type, prevout.scriptPubKey.AddressHash(), txhash, j, 1);
CMempoolAddressDelta delta(entry.GetTime(), prevout.nValue * -1, input.prevout.hash, input.prevout.n);
mapAddress.insert(make_pair(key, delta));
inserted.push_back(key);
}
}
- for (unsigned int k = 0; k < tx.vout.size(); k++) {
- const CTxOut &out = tx.vout[k];
- if (out.scriptPubKey.IsPayToScriptHash()) {
- vector<unsigned char> hashBytes(out.scriptPubKey.begin()+2, out.scriptPubKey.begin()+22);
- CMempoolAddressDeltaKey key(2, uint160(hashBytes), txhash, k, 0);
- mapAddress.insert(make_pair(key, CMempoolAddressDelta(entry.GetTime(), out.nValue)));
- inserted.push_back(key);
- } else if (out.scriptPubKey.IsPayToPublicKeyHash()) {
- vector<unsigned char> hashBytes(out.scriptPubKey.begin()+1, out.scriptPubKey.begin()+34);
- std::pair<addressDeltaMap::iterator,bool> ret;
- CMempoolAddressDeltaKey key(1, uint160(hashBytes), txhash, k, 0);
- mapAddress.insert(make_pair(key, CMempoolAddressDelta(entry.GetTime(), out.nValue)));
- inserted.push_back(key);
- }
+ for (unsigned int j = 0; j < tx.vout.size(); j++) {
+ const CTxOut &out = tx.vout[j];
+ CScript::ScriptType type = out.scriptPubKey.GetType();
+ if (type == CScript::UNKNOWN)
+ continue;
+ CMempoolAddressDeltaKey key(type, out.scriptPubKey.AddressHash(), txhash, j, 0);
+ mapAddress.insert(make_pair(key, CMempoolAddressDelta(entry.GetTime(), out.nValue)));
+ inserted.push_back(key);
}
mapAddressInserted.insert(make_pair(txhash, inserted));
}
-bool CTxMemPool::getAddressIndex(std::vector<std::pair<uint160, int> > &addresses,
- std::vector<std::pair<CMempoolAddressDeltaKey, CMempoolAddressDelta> > &results)
+bool CTxMemPool::getAddressIndex(const std::vector<std::pair<uint160, int> > &addresses, std::vector<std::pair<CMempoolAddressDeltaKey, CMempoolAddressDelta> > &results)
{
LOCK(cs);
- for (std::vector<std::pair<uint160, int> >::iterator it = addresses.begin(); it != addresses.end(); it++) {
- addressDeltaMap::iterator ait = mapAddress.lower_bound(CMempoolAddressDeltaKey((*it).second, (*it).first));
+ for (std::vector<std::pair<uint160, int> >::const_iterator it = addresses.begin(); it != addresses.end(); it++) {
+ auto ait = mapAddress.lower_bound(CMempoolAddressDeltaKey((*it).second, (*it).first));
while (ait != mapAddress.end() && (*ait).first.addressBytes == (*it).first && (*ait).first.type == (*it).second) {
results.push_back(*ait);
ait++;
bool CTxMemPool::removeAddressIndex(const uint256 txhash)
{
LOCK(cs);
- addressDeltaMapInserted::iterator it = mapAddressInserted.find(txhash);
+ auto it = mapAddressInserted.find(txhash);
if (it != mapAddressInserted.end()) {
std::vector<CMempoolAddressDeltaKey> keys = (*it).second;
void CTxMemPool::addSpentIndex(const CTxMemPoolEntry &entry, const CCoinsViewCache &view)
{
LOCK(cs);
-
const CTransaction& tx = entry.GetTx();
+ uint256 txhash = tx.GetHash();
std::vector<CSpentIndexKey> inserted;
- uint256 txhash = tx.GetHash();
for (unsigned int j = 0; j < tx.vin.size(); j++) {
const CTxIn input = tx.vin[j];
const CTxOut &prevout = view.GetOutputFor(input);
- uint160 addressHash;
- int addressType;
-
- if (prevout.scriptPubKey.IsPayToScriptHash()) {
- addressHash = uint160(vector<unsigned char> (prevout.scriptPubKey.begin()+2, prevout.scriptPubKey.begin()+22));
- addressType = 2;
- } else if (prevout.scriptPubKey.IsPayToPublicKeyHash()) {
- addressHash = uint160(vector<unsigned char> (prevout.scriptPubKey.begin()+1, prevout.scriptPubKey.begin()+34));
- addressType = 1;
- } else {
- addressHash.SetNull();
- addressType = 0;
- }
-
CSpentIndexKey key = CSpentIndexKey(input.prevout.hash, input.prevout.n);
- CSpentIndexValue value = CSpentIndexValue(txhash, j, -1, prevout.nValue, addressType, addressHash);
-
+ CSpentIndexValue value = CSpentIndexValue(txhash, j, -1, prevout.nValue,
+ prevout.scriptPubKey.GetType(),
+ prevout.scriptPubKey.AddressHash());
mapSpent.insert(make_pair(key, value));
inserted.push_back(key);
-
}
-
mapSpentInserted.insert(make_pair(txhash, inserted));
}
-bool CTxMemPool::getSpentIndex(CSpentIndexKey &key, CSpentIndexValue &value)
+bool CTxMemPool::getSpentIndex(const CSpentIndexKey &key, CSpentIndexValue &value)
{
LOCK(cs);
- mapSpentIndex::iterator it;
-
- it = mapSpent.find(key);
+ std::map<CSpentIndexKey, CSpentIndexValue, CSpentIndexKeyCompare>::iterator it = mapSpent.find(key);
if (it != mapSpent.end()) {
value = it->second;
return true;
bool CTxMemPool::removeSpentIndex(const uint256 txhash)
{
LOCK(cs);
- mapSpentIndexInserted::iterator it = mapSpentInserted.find(txhash);
+ auto it = mapSpentInserted.find(txhash);
if (it != mapSpentInserted.end()) {
std::vector<CSpentIndexKey> keys = (*it).second;
txToRemove.push_back(it->second.ptx->GetHash());
}
}
+ mapRecentlyAddedTx.erase(hash);
BOOST_FOREACH(const CTxIn& txin, tx.vin)
mapNextTx.erase(txin.prevout);
- BOOST_FOREACH(const JSDescription& joinsplit, tx.vjoinsplit) {
+ BOOST_FOREACH(const JSDescription& joinsplit, tx.vJoinSplit) {
BOOST_FOREACH(const uint256& nf, joinsplit.nullifiers) {
- mapNullifiers.erase(nf);
+ mapSproutNullifiers.erase(nf);
}
}
-
+ for (const SpendDescription &spendDescription : tx.vShieldedSpend) {
+ mapSaplingNullifiers.erase(spendDescription.nullifier);
+ }
removed.push_back(tx);
totalTxSize -= mapTx.find(hash)->GetTxSize();
cachedInnerUsage -= mapTx.find(hash)->DynamicMemoryUsage();
mapTx.erase(hash);
nTransactionsUpdated++;
minerPolicyEstimator->removeTx(hash);
- removeAddressIndex(hash);
- removeSpentIndex(hash);
+ if (fAddressIndex)
+ removeAddressIndex(hash);
+ if (fSpentIndex)
+ removeSpentIndex(hash);
+ ClearPrioritisation(tx.GetHash());
}
}
}
+extern uint64_t ASSETCHAINS_TIMELOCKGTE;
+int64_t komodo_block_unlocktime(uint32_t nHeight);
+
void CTxMemPool::removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMemPoolHeight, int flags)
{
// Remove transactions spending a coinbase which are now immature
extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
+
if ( ASSETCHAINS_SYMBOL[0] == 0 )
COINBASE_MATURITY = _COINBASE_MATURITY;
+
// Remove transactions spending a coinbase which are now immature and no-longer-final transactions
LOCK(cs);
list<CTransaction> transactionsToRemove;
if (it2 != mapTx.end())
continue;
const CCoins *coins = pcoins->AccessCoins(txin.prevout.hash);
- if (nCheckFrequency != 0) assert(coins);
- if (!coins || (coins->IsCoinBase() && ((signed long)nMemPoolHeight) - coins->nHeight < COINBASE_MATURITY)) {
+ if (nCheckFrequency != 0) assert(coins);
+
+ if (!coins || (coins->IsCoinBase() &&
+ (((signed long)nMemPoolHeight) - coins->nHeight < COINBASE_MATURITY) ||
+ ((signed long)nMemPoolHeight < komodo_block_unlocktime(coins->nHeight) &&
+ coins->IsAvailable(0) && coins->vout[0].nValue >= ASSETCHAINS_TIMELOCKGTE))) {
transactionsToRemove.push_back(tx);
break;
}
}
-void CTxMemPool::removeWithAnchor(const uint256 &invalidRoot)
+void CTxMemPool::removeWithAnchor(const uint256 &invalidRoot, ShieldedType type)
{
// If a block is disconnected from the tip, and the root changed,
// we must invalidate transactions from the mempool which spend
for (indexed_transaction_set::const_iterator it = mapTx.begin(); it != mapTx.end(); it++) {
const CTransaction& tx = it->GetTx();
- BOOST_FOREACH(const JSDescription& joinsplit, tx.vjoinsplit) {
- if (joinsplit.anchor == invalidRoot) {
- transactionsToRemove.push_back(tx);
- break;
- }
+ switch (type) {
+ case SPROUT:
+ BOOST_FOREACH(const JSDescription& joinsplit, tx.vJoinSplit) {
+ if (joinsplit.anchor == invalidRoot) {
+ transactionsToRemove.push_back(tx);
+ break;
+ }
+ }
+ break;
+ case SAPLING:
+ BOOST_FOREACH(const SpendDescription& spendDescription, tx.vShieldedSpend) {
+ if (spendDescription.anchor == invalidRoot) {
+ transactionsToRemove.push_back(tx);
+ break;
+ }
+ }
+ break;
+ default:
+ throw runtime_error("Unknown shielded type");
+ break;
}
}
}
}
- BOOST_FOREACH(const JSDescription &joinsplit, tx.vjoinsplit) {
+ BOOST_FOREACH(const JSDescription &joinsplit, tx.vJoinSplit) {
BOOST_FOREACH(const uint256 &nf, joinsplit.nullifiers) {
- std::map<uint256, const CTransaction*>::iterator it = mapNullifiers.find(nf);
- if (it != mapNullifiers.end()) {
+ std::map<uint256, const CTransaction*>::iterator it = mapSproutNullifiers.find(nf);
+ if (it != mapSproutNullifiers.end()) {
const CTransaction &txConflict = *it->second;
- if (txConflict != tx)
- {
+ if (txConflict != tx) {
remove(txConflict, removed, true);
}
}
}
}
+ for (const SpendDescription &spendDescription : tx.vShieldedSpend) {
+ std::map<uint256, const CTransaction*>::iterator it = mapSaplingNullifiers.find(spendDescription.nullifier);
+ if (it != mapSaplingNullifiers.end()) {
+ const CTransaction &txConflict = *it->second;
+ if (txConflict != tx) {
+ remove(txConflict, removed, true);
+ }
+ }
+ }
}
int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_t nTime,int32_t dispflag);
for (indexed_transaction_set::const_iterator it = mapTx.begin(); it != mapTx.end(); it++)
{
const CTransaction& tx = it->GetTx();
- tipindex = chainActive.Tip();
- if (IsExpiredTx(tx, nBlockHeight) || (ASSETCHAINS_SYMBOL[0] == 0 && tipindex != 0 && komodo_validate_interest(tx,tipindex->nHeight+1,tipindex->GetMedianTimePast() + 777,0)) < 0)
+ tipindex = chainActive.LastTip();
+ if (IsExpiredTx(tx, nBlockHeight) || (ASSETCHAINS_SYMBOL[0] == 0 && tipindex != 0 && komodo_validate_interest(tx,tipindex->GetHeight()+1,tipindex->GetMedianTimePast() + 777,0)) < 0)
{
transactionsToRemove.push_back(tx);
}
i++;
}
- boost::unordered_map<uint256, ZCIncrementalMerkleTree, CCoinsKeyHasher> intermediates;
+ boost::unordered_map<uint256, SproutMerkleTree, CCoinsKeyHasher> intermediates;
- BOOST_FOREACH(const JSDescription &joinsplit, tx.vjoinsplit) {
+ BOOST_FOREACH(const JSDescription &joinsplit, tx.vJoinSplit) {
BOOST_FOREACH(const uint256 &nf, joinsplit.nullifiers) {
- assert(!pcoins->GetNullifier(nf));
+ assert(!pcoins->GetNullifier(nf, SPROUT));
}
- ZCIncrementalMerkleTree tree;
+ SproutMerkleTree tree;
auto it = intermediates.find(joinsplit.anchor);
if (it != intermediates.end()) {
tree = it->second;
} else {
- assert(pcoins->GetAnchorAt(joinsplit.anchor, tree));
+ assert(pcoins->GetSproutAnchorAt(joinsplit.anchor, tree));
}
BOOST_FOREACH(const uint256& commitment, joinsplit.commitments)
intermediates.insert(std::make_pair(tree.root(), tree));
}
+ for (const SpendDescription &spendDescription : tx.vShieldedSpend) {
+ SaplingMerkleTree tree;
+
+ assert(pcoins->GetSaplingAnchorAt(spendDescription.anchor, tree));
+ assert(!pcoins->GetNullifier(spendDescription.nullifier, SAPLING));
+ }
if (fDependsWait)
waitingOnDependants.push_back(&(*it));
else {
assert(it->first == it->second.ptx->vin[it->second.n].prevout);
}
- for (std::map<uint256, const CTransaction*>::const_iterator it = mapNullifiers.begin(); it != mapNullifiers.end(); it++) {
- uint256 hash = it->second->GetHash();
- indexed_transaction_set::const_iterator it2 = mapTx.find(hash);
- const CTransaction& tx = it2->GetTx();
- assert(it2 != mapTx.end());
- assert(&tx == it->second);
- }
+ checkNullifiers(SPROUT);
+ checkNullifiers(SAPLING);
assert(totalTxSize == checkTotal);
assert(innerUsage == cachedInnerUsage);
}
+void CTxMemPool::checkNullifiers(ShieldedType type) const
+{
+ const std::map<uint256, const CTransaction*>* mapToUse;
+ switch (type) {
+ case SPROUT:
+ mapToUse = &mapSproutNullifiers;
+ break;
+ case SAPLING:
+ mapToUse = &mapSaplingNullifiers;
+ break;
+ default:
+ throw runtime_error("Unknown nullifier type");
+ }
+ for (const auto& entry : *mapToUse) {
+ uint256 hash = entry.second->GetHash();
+ CTxMemPool::indexed_transaction_set::const_iterator findTx = mapTx.find(hash);
+ const CTransaction& tx = findTx->GetTx();
+ assert(findTx != mapTx.end());
+ assert(&tx == entry.second);
+ }
+}
+
void CTxMemPool::queryHashes(vector<uint256>& vtxid)
{
vtxid.clear();
return true;
}
-void CTxMemPool::PrioritiseTransaction(const uint256 hash, const string strHash, double dPriorityDelta, const CAmount& nFeeDelta)
+void CTxMemPool::PrioritiseTransaction(const uint256 &hash, const string strHash, double dPriorityDelta, const CAmount& nFeeDelta)
{
{
LOCK(cs);
{
LOCK(cs);
mapDeltas.erase(hash);
+ mapReserveTransactions.erase(hash);
+}
+
+bool CTxMemPool::PrioritiseReserveTransaction(const CReserveTransactionDescriptor &txDesc, const CCurrencyState ¤cyState)
+{
+ LOCK(cs);
+ uint256 hash = txDesc.ptx->GetHash();
+ auto it = mapReserveTransactions.find(hash);
+ if (txDesc.IsValid())
+ {
+ mapReserveTransactions[hash] = txDesc;
+ CAmount feeDelta = currencyState.ReserveToNative(txDesc.ReserveFees() + txDesc.reserveConversionFees) + txDesc.nativeConversionFees;
+ PrioritiseTransaction(hash, hash.GetHex().c_str(), (double)feeDelta * 100.0, feeDelta);
+ return true;
+ }
+ return false;
+}
+
+bool CTxMemPool::IsKnownReserveTransaction(const uint256 &hash, CReserveTransactionDescriptor &txDesc)
+{
+ LOCK(cs);
+ auto it = mapReserveTransactions.find(hash);
+ if (it != mapReserveTransactions.end() && it->second.IsValid())
+ {
+ // refresh transaction from mempool or delete it if not found (we may not need this at all)
+ indexed_transaction_set::const_iterator i = mapTx.find(hash);
+ if (i == mapTx.end())
+ {
+ ClearPrioritisation(hash);
+ }
+ else
+ {
+ it->second.ptx = &(i->GetTx());
+
+ txDesc = it->second;
+ return true;
+ }
+ }
+ return false;
}
bool CTxMemPool::HasNoInputsOf(const CTransaction &tx) const
return true;
}
-CCoinsViewMemPool::CCoinsViewMemPool(CCoinsView *baseIn, CTxMemPool &mempoolIn) : CCoinsViewBacked(baseIn), mempool(mempoolIn) { }
+bool CTxMemPool::nullifierExists(const uint256& nullifier, ShieldedType type) const
+{
+ switch (type) {
+ case SPROUT:
+ return mapSproutNullifiers.count(nullifier);
+ case SAPLING:
+ return mapSaplingNullifiers.count(nullifier);
+ default:
+ throw runtime_error("Unknown nullifier type");
+ }
+}
-bool CCoinsViewMemPool::GetNullifier(const uint256 &nf) const {
- if (mempool.mapNullifiers.count(nf))
- return true;
+void CTxMemPool::NotifyRecentlyAdded()
+{
+ uint64_t recentlyAddedSequence;
+ std::vector<CTransaction> txs;
+ {
+ LOCK(cs);
+ recentlyAddedSequence = nRecentlyAddedSequence;
+ for (const auto& kv : mapRecentlyAddedTx) {
+ txs.push_back(*(kv.second));
+ }
+ mapRecentlyAddedTx.clear();
+ }
+
+ // A race condition can occur here between these SyncWithWallets calls, and
+ // the ones triggered by block logic (in ConnectTip and DisconnectTip). It
+ // is harmless because calling SyncWithWallets(_, NULL) does not alter the
+ // wallet transaction's block information.
+ for (auto tx : txs) {
+ try {
+ SyncWithWallets(tx, NULL);
+ } catch (const boost::thread_interrupted&) {
+ throw;
+ } catch (const std::exception& e) {
+ PrintExceptionContinue(&e, "CTxMemPool::NotifyRecentlyAdded()");
+ } catch (...) {
+ PrintExceptionContinue(NULL, "CTxMemPool::NotifyRecentlyAdded()");
+ }
+ }
+
+ // Update the notified sequence number. We only need this in regtest mode,
+ // and should not lock on cs after calling SyncWithWallets otherwise.
+ if (Params().NetworkIDString() == "regtest") {
+ LOCK(cs);
+ nNotifiedSequence = recentlyAddedSequence;
+ }
+}
- return base->GetNullifier(nf);
+bool CTxMemPool::IsFullyNotified() {
+ assert(Params().NetworkIDString() == "regtest");
+ LOCK(cs);
+ return nRecentlyAddedSequence == nNotifiedSequence;
+}
+
+CCoinsViewMemPool::CCoinsViewMemPool(CCoinsView *baseIn, CTxMemPool &mempoolIn) : CCoinsViewBacked(baseIn), mempool(mempoolIn) { }
+
+bool CCoinsViewMemPool::GetNullifier(const uint256 &nf, ShieldedType type) const
+{
+ return mempool.nullifierExists(nf, type) || base->GetNullifier(nf, type);
}
bool CCoinsViewMemPool::GetCoins(const uint256 &txid, CCoins &coins) const {
size_t CTxMemPool::DynamicMemoryUsage() const {
LOCK(cs);
// Estimate the overhead of mapTx to be 6 pointers + an allocation, as no exact formula for boost::multi_index_contained is implemented.
- return memusage::MallocUsage(sizeof(CTxMemPoolEntry) + 6 * sizeof(void*)) * mapTx.size() + memusage::DynamicUsage(mapNextTx) + memusage::DynamicUsage(mapDeltas) + cachedInnerUsage;
+ return memusage::MallocUsage(sizeof(CTxMemPoolEntry) + 6 * sizeof(void*)) * mapTx.size() + memusage::DynamicUsage(mapNextTx) + memusage::DynamicUsage(mapDeltas) + memusage::DynamicUsage(mapDeltas) + memusage::DynamicUsage(mapDeltas) + cachedInnerUsage;
}