Changeset View
Changeset View
Standalone View
Standalone View
src/miner.cpp
Show First 20 Lines • Show All 555 Lines • ▼ Show 20 Lines | while (mi != mempool.mapTx.get<ancestor_score>().end() || | ||||
// Update transactions that depend on each of these | // Update transactions that depend on each of these | ||||
nDescendantsUpdated += UpdatePackagesForAdded(ancestors, mapModifiedTx); | nDescendantsUpdated += UpdatePackagesForAdded(ancestors, mapModifiedTx); | ||||
} | } | ||||
} | } | ||||
void BlockAssembler::addPriorityTxs() { | void BlockAssembler::addPriorityTxs() { | ||||
// How much of the block should be dedicated to high-priority transactions, | // How much of the block should be dedicated to high-priority transactions, | ||||
// included regardless of the fees they pay. | // included regardless of the fees they pay. | ||||
uint64_t nBlockPrioritySize = | uint8_t nBlockPriorityPercentage = | ||||
GetArg("-blockprioritysize", DEFAULT_BLOCK_PRIORITY_SIZE); | GetArg("-blockprioritypercentage", DEFAULT_BLOCK_PRIORITY_PERCENTAGE); | ||||
nBlockPrioritySize = std::min(nMaxGeneratedBlockSize, nBlockPrioritySize); | if (nBlockPriorityPercentage == 0) { | ||||
deadalnix: This won't accurately check for absurd sizes. You need to get the value as a uint64_t at least… | |||||
sickpigAuthorUnsubmitted Not Done Inline Actionswe check it at init time, do we really need to check it twice? sickpig: we check it at init time, do we really need to check it twice?
see line 1279 of `init.cpp`. | |||||
deadalnixUnsubmitted Done Inline ActionsSpooky action at a distance is to be avoided. This code rely on the behavior of some other piece of code while there are no direct link between the 2. This kind of code is guaranteed to explode at some point when someone changes it. Sounds like adding this to the config object would be a much better idea. deadalnix: Spooky action at a distance is to be avoided. This code rely on the behavior of some other… | |||||
sickpigAuthorUnsubmitted Not Done Inline Actionsgood idea. going to do it. sickpig: good idea. going to do it. | |||||
sickpigAuthorUnsubmitted Not Done Inline Actionsit should be done see the last rev (1319) sickpig: it should be done see the last rev (1319) | |||||
if (nBlockPrioritySize == 0) { | |||||
return; | return; | ||||
} | } | ||||
uint64_t nBlockPrioritySize = | |||||
nMaxGeneratedBlockSize * nBlockPriorityPercentage / 100; | |||||
// This vector will be sorted into a priority queue: | // This vector will be sorted into a priority queue: | ||||
std::vector<TxCoinAgePriority> vecPriority; | std::vector<TxCoinAgePriority> vecPriority; | ||||
TxCoinAgePriorityCompare pricomparer; | TxCoinAgePriorityCompare pricomparer; | ||||
std::map<CTxMemPool::txiter, double, CTxMemPool::CompareIteratorByHash> | std::map<CTxMemPool::txiter, double, CTxMemPool::CompareIteratorByHash> | ||||
waitPriMap; | waitPriMap; | ||||
typedef std::map<CTxMemPool::txiter, double, | typedef std::map<CTxMemPool::txiter, double, | ||||
CTxMemPool::CompareIteratorByHash>::iterator waitPriIter; | CTxMemPool::CompareIteratorByHash>::iterator waitPriIter; | ||||
double actualPriority = -1; | double actualPriority = -1; | ||||
vecPriority.reserve(mempool.mapTx.size()); | vecPriority.reserve(mempool.mapTx.size()); | ||||
for (CTxMemPool::indexed_transaction_set::iterator mi = | for (CTxMemPool::indexed_transaction_set::iterator mi = | ||||
mempool.mapTx.begin(); | mempool.mapTx.begin(); | ||||
mi != mempool.mapTx.end(); ++mi) { | mi != mempool.mapTx.end(); ++mi) { | ||||
double dPriority = mi->GetPriority(nHeight); | double dPriority = mi->GetPriority(nHeight); | ||||
CAmount dummy; | CAmount dummy; | ||||
mempool.ApplyDeltas(mi->GetTx().GetId(), dPriority, dummy); | mempool.ApplyDeltas(mi->GetTx().GetId(), dPriority, dummy); | ||||
vecPriority.push_back(TxCoinAgePriority(dPriority, mi)); | vecPriority.push_back(TxCoinAgePriority(dPriority, mi)); | ||||
} | } | ||||
std::make_heap(vecPriority.begin(), vecPriority.end(), pricomparer); | std::make_heap(vecPriority.begin(), vecPriority.end(), pricomparer); | ||||
CTxMemPool::txiter iter; | CTxMemPool::txiter iter; | ||||
// Add a tx from priority queue to fill the blockprioritysize. | // Add a tx from priority queue to fill the part of block reserved to | ||||
// priority transactions. | |||||
while (!vecPriority.empty() && !blockFinished) { | while (!vecPriority.empty() && !blockFinished) { | ||||
iter = vecPriority.front().second; | iter = vecPriority.front().second; | ||||
actualPriority = vecPriority.front().first; | actualPriority = vecPriority.front().first; | ||||
std::pop_heap(vecPriority.begin(), vecPriority.end(), pricomparer); | std::pop_heap(vecPriority.begin(), vecPriority.end(), pricomparer); | ||||
vecPriority.pop_back(); | vecPriority.pop_back(); | ||||
// If tx already in block, skip. | // If tx already in block, skip. | ||||
if (inBlock.count(iter)) { | if (inBlock.count(iter)) { | ||||
▲ Show 20 Lines • Show All 62 Lines • Show Last 20 Lines |
This won't accurately check for absurd sizes. You need to get the value as a uint64_t at least and check that is is smaller than or equal to 100.