Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mempool #12

Merged
merged 2 commits into from
Jan 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ bool BlockAssembler::TestPackageTransactions(const CTxMemPool::setEntries& packa

void BlockAssembler::AddToBlock(CTxMemPool::txiter iter)
{
if(VeriBlock::isPopTx(*iter->GetSharedTx())) {
++nPopTx;
}
pblock->vtx.emplace_back(iter->GetSharedTx());
pblocktemplate->vTxFees.push_back(iter->GetFee());
pblocktemplate->vTxSigOpsCost.push_back(iter->GetSigOpCost());
Expand Down Expand Up @@ -306,8 +309,6 @@ void BlockAssembler::SortForBlock(const CTxMemPool::setEntries& package, std::ve
template<typename MempoolComparatorTagName>
void BlockAssembler::addPackageTxs(int &nPackagesSelected, int &nDescendantsUpdated)
{
// count of pop txs
size_t popTxCount = 0 ;
auto& config = VeriBlock::getService<VeriBlock::Config>();

// mapModifiedTx will store sorted packages after they are modified
Expand Down Expand Up @@ -426,14 +427,11 @@ void BlockAssembler::addPackageTxs(int &nPackagesSelected, int &nDescendantsUpda
SortForBlock(ancestors, sortedEntries);

for (size_t i=0; i<sortedEntries.size(); ++i) {
AddToBlock(sortedEntries[i]);
if (!(nPopTx >= config.max_pop_tx_amount && VeriBlock::isPopTx(*sortedEntries[i]->GetSharedTx()))){
AddToBlock(sortedEntries[i]);
}
// Erase from the modified set, if present
mapModifiedTx.erase(sortedEntries[i]);
if (VeriBlock::isPopTx(*sortedEntries[i]->GetSharedTx())) {
++popTxCount;
if (popTxCount == config.max_pop_tx_amount)
return;
}
}

++nPackagesSelected;
Expand Down
1 change: 1 addition & 0 deletions src/miner.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ class BlockAssembler
// Information on the current status of the block
uint64_t nBlockWeight;
uint64_t nBlockTx;
uint64_t nPopTx = 0;
uint64_t nBlockSigOpsCost;
CAmount nFees;
CTxMemPool::setEntries inBlock;
Expand Down