mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
Return shared_ptr<CTransaction> from mempool removes
This commit is contained in:
parent
51f278329d
commit
4100499db4
10
src/main.cpp
10
src/main.cpp
@ -2803,7 +2803,7 @@ static int64_t nTimePostConnect = 0;
|
||||
* Connect a new block to chainActive. pblock is either NULL or a pointer to a CBlock
|
||||
* corresponding to pindexNew, to bypass loading it again from disk.
|
||||
*/
|
||||
bool static ConnectTip(CValidationState& state, const CChainParams& chainparams, CBlockIndex* pindexNew, const CBlock* pblock, std::list<CTransaction> &txConflicted, std::vector<std::tuple<CTransaction,CBlockIndex*,int>> &txChanged)
|
||||
bool static ConnectTip(CValidationState& state, const CChainParams& chainparams, CBlockIndex* pindexNew, const CBlock* pblock, std::vector<std::shared_ptr<const CTransaction>> &txConflicted, std::vector<std::tuple<CTransaction,CBlockIndex*,int>> &txChanged)
|
||||
{
|
||||
assert(pindexNew->pprev == chainActive.Tip());
|
||||
// Read block from disk.
|
||||
@ -2926,7 +2926,7 @@ static void PruneBlockIndexCandidates() {
|
||||
* Try to make some progress towards making pindexMostWork the active block.
|
||||
* pblock is either NULL or a pointer to a CBlock corresponding to pindexMostWork.
|
||||
*/
|
||||
static bool ActivateBestChainStep(CValidationState& state, const CChainParams& chainparams, CBlockIndex* pindexMostWork, const CBlock* pblock, bool& fInvalidFound, std::list<CTransaction>& txConflicted, std::vector<std::tuple<CTransaction,CBlockIndex*,int>>& txChanged)
|
||||
static bool ActivateBestChainStep(CValidationState& state, const CChainParams& chainparams, CBlockIndex* pindexMostWork, const CBlock* pblock, bool& fInvalidFound, std::vector<std::shared_ptr<const CTransaction>>& txConflicted, std::vector<std::tuple<CTransaction,CBlockIndex*,int>>& txChanged)
|
||||
{
|
||||
AssertLockHeld(cs_main);
|
||||
const CBlockIndex *pindexOldTip = chainActive.Tip();
|
||||
@ -3037,7 +3037,7 @@ bool ActivateBestChain(CValidationState &state, const CChainParams& chainparams,
|
||||
break;
|
||||
|
||||
const CBlockIndex *pindexFork;
|
||||
std::list<CTransaction> txConflicted;
|
||||
std::vector<std::shared_ptr<const CTransaction>> txConflicted;
|
||||
bool fInitialDownload;
|
||||
{
|
||||
LOCK(cs_main);
|
||||
@ -3068,9 +3068,9 @@ bool ActivateBestChain(CValidationState &state, const CChainParams& chainparams,
|
||||
|
||||
// throw all transactions though the signal-interface
|
||||
// while _not_ holding the cs_main lock
|
||||
BOOST_FOREACH(const CTransaction &tx, txConflicted)
|
||||
for(std::shared_ptr<const CTransaction> tx : txConflicted)
|
||||
{
|
||||
GetMainSignals().SyncTransaction(tx, pindexNewTip, CMainSignals::SYNC_TRANSACTION_NOT_IN_BLOCK);
|
||||
GetMainSignals().SyncTransaction(*tx, pindexNewTip, CMainSignals::SYNC_TRANSACTION_NOT_IN_BLOCK);
|
||||
}
|
||||
// ... and about transactions that got confirmed:
|
||||
for(unsigned int i = 0; i < txChanged.size(); i++)
|
||||
|
@ -80,7 +80,7 @@ BOOST_AUTO_TEST_CASE(SimpleRoundTripTest)
|
||||
|
||||
BOOST_CHECK_EQUAL(pool.mapTx.find(block.vtx[2].GetHash())->GetSharedTx().use_count(), SHARED_TX_OFFSET + 1);
|
||||
|
||||
std::list<CTransaction> removed;
|
||||
std::vector<std::shared_ptr<const CTransaction>> removed;
|
||||
pool.removeRecursive(block.vtx[2], &removed);
|
||||
BOOST_CHECK_EQUAL(removed.size(), 1);
|
||||
|
||||
|
@ -55,7 +55,7 @@ BOOST_AUTO_TEST_CASE(MempoolRemoveTest)
|
||||
|
||||
|
||||
CTxMemPool testPool(CFeeRate(0));
|
||||
std::list<CTransaction> removed;
|
||||
std::vector<std::shared_ptr<const CTransaction>> removed;
|
||||
|
||||
// Nothing in pool, remove should do nothing:
|
||||
testPool.removeRecursive(txParent, &removed);
|
||||
@ -547,6 +547,7 @@ BOOST_AUTO_TEST_CASE(MempoolSizeLimitTest)
|
||||
pool.addUnchecked(tx7.GetHash(), entry.Fee(9000LL).FromTx(tx7, &pool));
|
||||
|
||||
std::vector<CTransaction> vtx;
|
||||
std::vector<std::shared_ptr<const CTransaction>> conflicts;
|
||||
SetMockTime(42);
|
||||
SetMockTime(42 + CTxMemPool::ROLLING_FEE_HALFLIFE);
|
||||
BOOST_CHECK_EQUAL(pool.GetMinFee(1).GetFeePerK(), maxFeeRateRemoved.GetFeePerK() + 1000);
|
||||
|
@ -503,7 +503,7 @@ void CTxMemPool::CalculateDescendants(txiter entryit, setEntries &setDescendants
|
||||
}
|
||||
}
|
||||
|
||||
void CTxMemPool::removeRecursive(const CTransaction &origTx, std::list<CTransaction>* removed)
|
||||
void CTxMemPool::removeRecursive(const CTransaction &origTx, std::vector<std::shared_ptr<const CTransaction>>* removed)
|
||||
{
|
||||
// Remove transaction from memory pool
|
||||
{
|
||||
@ -532,7 +532,7 @@ void CTxMemPool::removeRecursive(const CTransaction &origTx, std::list<CTransact
|
||||
}
|
||||
if (removed) {
|
||||
BOOST_FOREACH(txiter it, setAllRemoves) {
|
||||
removed->push_back(it->GetTx());
|
||||
removed->emplace_back(it->GetSharedTx());
|
||||
}
|
||||
}
|
||||
RemoveStaged(setAllRemoves, false);
|
||||
@ -576,7 +576,7 @@ void CTxMemPool::removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMem
|
||||
RemoveStaged(setAllRemoves, false);
|
||||
}
|
||||
|
||||
void CTxMemPool::removeConflicts(const CTransaction &tx, std::list<CTransaction>* removed)
|
||||
void CTxMemPool::removeConflicts(const CTransaction &tx, std::vector<std::shared_ptr<const CTransaction>>* removed)
|
||||
{
|
||||
// Remove transactions which depend on inputs of tx, recursively
|
||||
LOCK(cs);
|
||||
@ -597,7 +597,7 @@ void CTxMemPool::removeConflicts(const CTransaction &tx, std::list<CTransaction>
|
||||
* Called when a block is connected. Removes from mempool and updates the miner fee estimator.
|
||||
*/
|
||||
void CTxMemPool::removeForBlock(const std::vector<CTransaction>& vtx, unsigned int nBlockHeight,
|
||||
std::list<CTransaction>* conflicts, bool fCurrentEstimate)
|
||||
std::vector<std::shared_ptr<const CTransaction>>* conflicts, bool fCurrentEstimate)
|
||||
{
|
||||
LOCK(cs);
|
||||
std::vector<CTxMemPoolEntry> entries;
|
||||
|
@ -6,7 +6,6 @@
|
||||
#ifndef BITCOIN_TXMEMPOOL_H
|
||||
#define BITCOIN_TXMEMPOOL_H
|
||||
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
|
||||
@ -521,11 +520,11 @@ public:
|
||||
bool addUnchecked(const uint256& hash, const CTxMemPoolEntry &entry, bool fCurrentEstimate = true);
|
||||
bool addUnchecked(const uint256& hash, const CTxMemPoolEntry &entry, setEntries &setAncestors, bool fCurrentEstimate = true);
|
||||
|
||||
void removeRecursive(const CTransaction &tx, std::list<CTransaction>* removed = NULL);
|
||||
void removeRecursive(const CTransaction &tx, std::vector<std::shared_ptr<const CTransaction>>* removed = NULL);
|
||||
void removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMemPoolHeight, int flags);
|
||||
void removeConflicts(const CTransaction &tx, std::list<CTransaction>* removed = NULL);
|
||||
void removeConflicts(const CTransaction &tx, std::vector<std::shared_ptr<const CTransaction>>* removed = NULL);
|
||||
void removeForBlock(const std::vector<CTransaction>& vtx, unsigned int nBlockHeight,
|
||||
std::list<CTransaction>* conflicts = NULL, bool fCurrentEstimate = true);
|
||||
std::vector<std::shared_ptr<const CTransaction>>* conflicts = NULL, bool fCurrentEstimate = true);
|
||||
void clear();
|
||||
void _clear(); //lock free
|
||||
bool CompareDepthAndScore(const uint256& hasha, const uint256& hashb);
|
||||
|
Loading…
Reference in New Issue
Block a user