|
|
@ -23,7 +23,7 @@ set<CWallet*> setpwalletRegistered; |
|
|
|
|
|
|
|
|
|
|
|
CCriticalSection cs_main; |
|
|
|
CCriticalSection cs_main; |
|
|
|
|
|
|
|
|
|
|
|
static CTxMemPool mempool; |
|
|
|
CTxMemPool mempool; |
|
|
|
unsigned int nTransactionsUpdated = 0; |
|
|
|
unsigned int nTransactionsUpdated = 0; |
|
|
|
|
|
|
|
|
|
|
|
map<uint256, CBlockIndex*> mapBlockIndex; |
|
|
|
map<uint256, CBlockIndex*> mapBlockIndex; |
|
|
@ -576,9 +576,9 @@ bool CTransaction::AcceptToMemoryPool(CTxDB& txdb, bool fCheckInputs, bool* pfMi |
|
|
|
if (ptxOld) |
|
|
|
if (ptxOld) |
|
|
|
{ |
|
|
|
{ |
|
|
|
printf("AcceptToMemoryPool() : replacing tx %s with new version\n", ptxOld->GetHash().ToString().c_str()); |
|
|
|
printf("AcceptToMemoryPool() : replacing tx %s with new version\n", ptxOld->GetHash().ToString().c_str()); |
|
|
|
ptxOld->RemoveFromMemoryPool(); |
|
|
|
mempool.remove(*ptxOld); |
|
|
|
} |
|
|
|
} |
|
|
|
AddToMemoryPoolUnchecked(); |
|
|
|
mempool.addUnchecked(*this); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
///// are we sure this is ok when loading transactions or restoring block txes
|
|
|
|
///// are we sure this is ok when loading transactions or restoring block txes
|
|
|
@ -590,39 +590,35 @@ bool CTransaction::AcceptToMemoryPool(CTxDB& txdb, bool fCheckInputs, bool* pfMi |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
uint64 nPooledTx = 0; |
|
|
|
bool CTxMemPool::addUnchecked(CTransaction &tx) |
|
|
|
|
|
|
|
|
|
|
|
bool CTransaction::AddToMemoryPoolUnchecked() |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
printf("AcceptToMemoryPoolUnchecked(): size %lu\n", mempool.mapTx.size()); |
|
|
|
printf("AcceptToMemoryPoolUnchecked(): size %lu\n", mapTx.size()); |
|
|
|
// Add to memory pool without checking anything. Don't call this directly,
|
|
|
|
// Add to memory pool without checking anything. Don't call this directly,
|
|
|
|
// call AcceptToMemoryPool to properly check the transaction first.
|
|
|
|
// call AcceptToMemoryPool to properly check the transaction first.
|
|
|
|
{ |
|
|
|
{ |
|
|
|
LOCK(mempool.cs); |
|
|
|
LOCK(cs); |
|
|
|
uint256 hash = GetHash(); |
|
|
|
uint256 hash = tx.GetHash(); |
|
|
|
mempool.mapTx[hash] = *this; |
|
|
|
mapTx[hash] = tx; |
|
|
|
for (int i = 0; i < vin.size(); i++) |
|
|
|
for (int i = 0; i < tx.vin.size(); i++) |
|
|
|
mempool.mapNextTx[vin[i].prevout] = CInPoint(&mempool.mapTx[hash], i); |
|
|
|
mapNextTx[tx.vin[i].prevout] = CInPoint(&mapTx[hash], i); |
|
|
|
nTransactionsUpdated++; |
|
|
|
nTransactionsUpdated++; |
|
|
|
++nPooledTx; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool CTransaction::RemoveFromMemoryPool() |
|
|
|
bool CTxMemPool::remove(CTransaction &tx) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Remove transaction from memory pool
|
|
|
|
// Remove transaction from memory pool
|
|
|
|
{ |
|
|
|
{ |
|
|
|
LOCK(mempool.cs); |
|
|
|
LOCK(cs); |
|
|
|
uint256 hash = GetHash(); |
|
|
|
uint256 hash = tx.GetHash(); |
|
|
|
if (mempool.mapTx.count(hash)) |
|
|
|
if (mapTx.count(hash)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
BOOST_FOREACH(const CTxIn& txin, vin) |
|
|
|
BOOST_FOREACH(const CTxIn& txin, tx.vin) |
|
|
|
mempool.mapNextTx.erase(txin.prevout); |
|
|
|
mapNextTx.erase(txin.prevout); |
|
|
|
mempool.mapTx.erase(hash); |
|
|
|
mapTx.erase(hash); |
|
|
|
nTransactionsUpdated++; |
|
|
|
nTransactionsUpdated++; |
|
|
|
--nPooledTx; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return true; |
|
|
|
return true; |
|
|
@ -1435,7 +1431,7 @@ bool static Reorganize(CTxDB& txdb, CBlockIndex* pindexNew) |
|
|
|
|
|
|
|
|
|
|
|
// Delete redundant memory transactions that are in the connected branch
|
|
|
|
// Delete redundant memory transactions that are in the connected branch
|
|
|
|
BOOST_FOREACH(CTransaction& tx, vDelete) |
|
|
|
BOOST_FOREACH(CTransaction& tx, vDelete) |
|
|
|
tx.RemoveFromMemoryPool(); |
|
|
|
mempool.remove(tx); |
|
|
|
|
|
|
|
|
|
|
|
printf("REORGANIZE: done\n"); |
|
|
|
printf("REORGANIZE: done\n"); |
|
|
|
|
|
|
|
|
|
|
@ -1471,7 +1467,7 @@ bool CBlock::SetBestChainInner(CTxDB& txdb, CBlockIndex *pindexNew) |
|
|
|
|
|
|
|
|
|
|
|
// Delete redundant memory transactions
|
|
|
|
// Delete redundant memory transactions
|
|
|
|
BOOST_FOREACH(CTransaction& tx, vtx) |
|
|
|
BOOST_FOREACH(CTransaction& tx, vtx) |
|
|
|
tx.RemoveFromMemoryPool(); |
|
|
|
mempool.remove(tx); |
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|