mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 13:03:17 +01:00
Make feeEstimator its own global instance of CBlockPolicyEstimator
This commit is contained in:
parent
e183ea2047
commit
ae7327b832
@ -16,7 +16,8 @@ BOOST_FIXTURE_TEST_SUITE(policyestimator_tests, BasicTestingSetup)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(BlockPolicyEstimates)
|
BOOST_AUTO_TEST_CASE(BlockPolicyEstimates)
|
||||||
{
|
{
|
||||||
CTxMemPool mpool;
|
CBlockPolicyEstimator feeEst;
|
||||||
|
CTxMemPool mpool(&feeEst);
|
||||||
TestMemPoolEntryHelper entry;
|
TestMemPoolEntryHelper entry;
|
||||||
CAmount basefee(2000);
|
CAmount basefee(2000);
|
||||||
CAmount deltaFee(100);
|
CAmount deltaFee(100);
|
||||||
|
@ -333,8 +333,8 @@ void CTxMemPoolEntry::UpdateAncestorState(int64_t modifySize, CAmount modifyFee,
|
|||||||
assert(int(nSigOpCostWithAncestors) >= 0);
|
assert(int(nSigOpCostWithAncestors) >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
CTxMemPool::CTxMemPool() :
|
CTxMemPool::CTxMemPool(CBlockPolicyEstimator* estimator) :
|
||||||
nTransactionsUpdated(0)
|
nTransactionsUpdated(0), minerPolicyEstimator(estimator)
|
||||||
{
|
{
|
||||||
_clear(); //lock free clear
|
_clear(); //lock free clear
|
||||||
|
|
||||||
@ -342,13 +342,6 @@ CTxMemPool::CTxMemPool() :
|
|||||||
// accepting transactions becomes O(N^2) where N is the number
|
// accepting transactions becomes O(N^2) where N is the number
|
||||||
// of transactions in the pool
|
// of transactions in the pool
|
||||||
nCheckFrequency = 0;
|
nCheckFrequency = 0;
|
||||||
|
|
||||||
minerPolicyEstimator = new CBlockPolicyEstimator();
|
|
||||||
}
|
|
||||||
|
|
||||||
CTxMemPool::~CTxMemPool()
|
|
||||||
{
|
|
||||||
delete minerPolicyEstimator;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTxMemPool::pruneSpent(const uint256 &hashTx, CCoins &coins)
|
void CTxMemPool::pruneSpent(const uint256 &hashTx, CCoins &coins)
|
||||||
@ -427,7 +420,7 @@ bool CTxMemPool::addUnchecked(const uint256& hash, const CTxMemPoolEntry &entry,
|
|||||||
|
|
||||||
nTransactionsUpdated++;
|
nTransactionsUpdated++;
|
||||||
totalTxSize += entry.GetTxSize();
|
totalTxSize += entry.GetTxSize();
|
||||||
minerPolicyEstimator->processTransaction(entry, validFeeEstimate);
|
if (minerPolicyEstimator) {minerPolicyEstimator->processTransaction(entry, validFeeEstimate);}
|
||||||
|
|
||||||
vTxHashes.emplace_back(tx.GetWitnessHash(), newit);
|
vTxHashes.emplace_back(tx.GetWitnessHash(), newit);
|
||||||
newit->vTxHashesIdx = vTxHashes.size() - 1;
|
newit->vTxHashesIdx = vTxHashes.size() - 1;
|
||||||
@ -457,7 +450,7 @@ void CTxMemPool::removeUnchecked(txiter it, MemPoolRemovalReason reason)
|
|||||||
mapLinks.erase(it);
|
mapLinks.erase(it);
|
||||||
mapTx.erase(it);
|
mapTx.erase(it);
|
||||||
nTransactionsUpdated++;
|
nTransactionsUpdated++;
|
||||||
minerPolicyEstimator->removeTx(hash);
|
if (minerPolicyEstimator) {minerPolicyEstimator->removeTx(hash);}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculates descendants of entry that are not already in setDescendants, and adds to
|
// Calculates descendants of entry that are not already in setDescendants, and adds to
|
||||||
@ -591,7 +584,7 @@ void CTxMemPool::removeForBlock(const std::vector<CTransactionRef>& vtx, unsigne
|
|||||||
entries.push_back(&*i);
|
entries.push_back(&*i);
|
||||||
}
|
}
|
||||||
// Before the txs in the new block have been removed from the mempool, update policy estimates
|
// Before the txs in the new block have been removed from the mempool, update policy estimates
|
||||||
minerPolicyEstimator->processBlock(nBlockHeight, entries);
|
if (minerPolicyEstimator) {minerPolicyEstimator->processBlock(nBlockHeight, entries);}
|
||||||
for (const auto& tx : vtx)
|
for (const auto& tx : vtx)
|
||||||
{
|
{
|
||||||
txiter it = mapTx.find(tx->GetHash());
|
txiter it = mapTx.find(tx->GetHash());
|
||||||
|
@ -496,8 +496,7 @@ public:
|
|||||||
|
|
||||||
/** Create a new CTxMemPool.
|
/** Create a new CTxMemPool.
|
||||||
*/
|
*/
|
||||||
CTxMemPool();
|
CTxMemPool(CBlockPolicyEstimator* estimator = nullptr);
|
||||||
~CTxMemPool();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If sanity-checking is turned on, check makes sure the pool is
|
* If sanity-checking is turned on, check makes sure the pool is
|
||||||
|
@ -80,7 +80,8 @@ uint256 hashAssumeValid;
|
|||||||
CFeeRate minRelayTxFee = CFeeRate(DEFAULT_MIN_RELAY_TX_FEE);
|
CFeeRate minRelayTxFee = CFeeRate(DEFAULT_MIN_RELAY_TX_FEE);
|
||||||
CAmount maxTxFee = DEFAULT_TRANSACTION_MAXFEE;
|
CAmount maxTxFee = DEFAULT_TRANSACTION_MAXFEE;
|
||||||
|
|
||||||
CTxMemPool mempool;
|
CBlockPolicyEstimator feeEstimator;
|
||||||
|
CTxMemPool mempool(&feeEstimator);
|
||||||
|
|
||||||
static void CheckBlockIndex(const Consensus::Params& consensusParams);
|
static void CheckBlockIndex(const Consensus::Params& consensusParams);
|
||||||
|
|
||||||
|
@ -39,6 +39,7 @@ class CChainParams;
|
|||||||
class CInv;
|
class CInv;
|
||||||
class CConnman;
|
class CConnman;
|
||||||
class CScriptCheck;
|
class CScriptCheck;
|
||||||
|
class CBlockPolicyEstimator;
|
||||||
class CTxMemPool;
|
class CTxMemPool;
|
||||||
class CValidationInterface;
|
class CValidationInterface;
|
||||||
class CValidationState;
|
class CValidationState;
|
||||||
@ -152,6 +153,7 @@ struct BlockHasher
|
|||||||
|
|
||||||
extern CScript COINBASE_FLAGS;
|
extern CScript COINBASE_FLAGS;
|
||||||
extern CCriticalSection cs_main;
|
extern CCriticalSection cs_main;
|
||||||
|
extern CBlockPolicyEstimator feeEstimator;
|
||||||
extern CTxMemPool mempool;
|
extern CTxMemPool mempool;
|
||||||
typedef boost::unordered_map<uint256, CBlockIndex*, BlockHasher> BlockMap;
|
typedef boost::unordered_map<uint256, CBlockIndex*, BlockHasher> BlockMap;
|
||||||
extern BlockMap mapBlockIndex;
|
extern BlockMap mapBlockIndex;
|
||||||
|
Loading…
Reference in New Issue
Block a user