mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 21:12:48 +01:00
Pass pointers to existing CTxMemPoolEntries to fee estimation
This commit is contained in:
parent
d825838e64
commit
ebafdcabb1
@ -334,9 +334,9 @@ void CBlockPolicyEstimator::processTransaction(const CTxMemPoolEntry& entry, boo
|
|||||||
mapMemPoolTxs[hash].bucketIndex = feeStats.NewTx(txHeight, (double)feeRate.GetFeePerK());
|
mapMemPoolTxs[hash].bucketIndex = feeStats.NewTx(txHeight, (double)feeRate.GetFeePerK());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBlockPolicyEstimator::processBlockTx(unsigned int nBlockHeight, const CTxMemPoolEntry& entry)
|
void CBlockPolicyEstimator::processBlockTx(unsigned int nBlockHeight, const CTxMemPoolEntry* entry)
|
||||||
{
|
{
|
||||||
if (!removeTx(entry.GetTx().GetHash())) {
|
if (!removeTx(entry->GetTx().GetHash())) {
|
||||||
// This transaction wasn't being tracked for fee estimation
|
// This transaction wasn't being tracked for fee estimation
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -344,7 +344,7 @@ void CBlockPolicyEstimator::processBlockTx(unsigned int nBlockHeight, const CTxM
|
|||||||
// How many blocks did it take for miners to include this transaction?
|
// How many blocks did it take for miners to include this transaction?
|
||||||
// blocksToConfirm is 1-based, so a transaction included in the earliest
|
// blocksToConfirm is 1-based, so a transaction included in the earliest
|
||||||
// possible block has confirmation count of 1
|
// possible block has confirmation count of 1
|
||||||
int blocksToConfirm = nBlockHeight - entry.GetHeight();
|
int blocksToConfirm = nBlockHeight - entry->GetHeight();
|
||||||
if (blocksToConfirm <= 0) {
|
if (blocksToConfirm <= 0) {
|
||||||
// This can't happen because we don't process transactions from a block with a height
|
// This can't happen because we don't process transactions from a block with a height
|
||||||
// lower than our greatest seen height
|
// lower than our greatest seen height
|
||||||
@ -353,13 +353,13 @@ void CBlockPolicyEstimator::processBlockTx(unsigned int nBlockHeight, const CTxM
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Feerates are stored and reported as BTC-per-kb:
|
// Feerates are stored and reported as BTC-per-kb:
|
||||||
CFeeRate feeRate(entry.GetFee(), entry.GetTxSize());
|
CFeeRate feeRate(entry->GetFee(), entry->GetTxSize());
|
||||||
|
|
||||||
feeStats.Record(blocksToConfirm, (double)feeRate.GetFeePerK());
|
feeStats.Record(blocksToConfirm, (double)feeRate.GetFeePerK());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBlockPolicyEstimator::processBlock(unsigned int nBlockHeight,
|
void CBlockPolicyEstimator::processBlock(unsigned int nBlockHeight,
|
||||||
std::vector<CTxMemPoolEntry>& entries)
|
std::vector<const CTxMemPoolEntry*>& entries)
|
||||||
{
|
{
|
||||||
if (nBlockHeight <= nBestSeenHeight) {
|
if (nBlockHeight <= nBestSeenHeight) {
|
||||||
// Ignore side chains and re-orgs; assuming they are random
|
// Ignore side chains and re-orgs; assuming they are random
|
||||||
|
@ -203,10 +203,10 @@ public:
|
|||||||
|
|
||||||
/** Process all the transactions that have been included in a block */
|
/** Process all the transactions that have been included in a block */
|
||||||
void processBlock(unsigned int nBlockHeight,
|
void processBlock(unsigned int nBlockHeight,
|
||||||
std::vector<CTxMemPoolEntry>& entries);
|
std::vector<const CTxMemPoolEntry*>& entries);
|
||||||
|
|
||||||
/** Process a transaction confirmed in a block*/
|
/** Process a transaction confirmed in a block*/
|
||||||
void processBlockTx(unsigned int nBlockHeight, const CTxMemPoolEntry& entry);
|
void processBlockTx(unsigned int nBlockHeight, const CTxMemPoolEntry* entry);
|
||||||
|
|
||||||
/** Process a transaction accepted to the mempool*/
|
/** Process a transaction accepted to the mempool*/
|
||||||
void processTransaction(const CTxMemPoolEntry& entry, bool validFeeEstimate);
|
void processTransaction(const CTxMemPoolEntry& entry, bool validFeeEstimate);
|
||||||
|
@ -594,14 +594,14 @@ void CTxMemPool::removeConflicts(const CTransaction &tx)
|
|||||||
void CTxMemPool::removeForBlock(const std::vector<CTransactionRef>& vtx, unsigned int nBlockHeight)
|
void CTxMemPool::removeForBlock(const std::vector<CTransactionRef>& vtx, unsigned int nBlockHeight)
|
||||||
{
|
{
|
||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
std::vector<CTxMemPoolEntry> entries;
|
std::vector<const CTxMemPoolEntry*> entries;
|
||||||
for (const auto& tx : vtx)
|
for (const auto& tx : vtx)
|
||||||
{
|
{
|
||||||
uint256 hash = tx->GetHash();
|
uint256 hash = tx->GetHash();
|
||||||
|
|
||||||
indexed_transaction_set::iterator i = mapTx.find(hash);
|
indexed_transaction_set::iterator i = mapTx.find(hash);
|
||||||
if (i != mapTx.end())
|
if (i != mapTx.end())
|
||||||
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);
|
minerPolicyEstimator->processBlock(nBlockHeight, entries);
|
||||||
|
Loading…
Reference in New Issue
Block a user