mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-16 13:01:19 +02:00
Merge a4d7ac7bbe into merged_master (Elements PR #1317)
This commit is contained in:
commit
9c1d4cc8ff
17 changed files with 653 additions and 24 deletions
|
|
@ -304,6 +304,7 @@ int BlockAssembler::UpdatePackagesForAdded(const CTxMemPool::setEntries& already
|
|||
if (mit == mapModifiedTx.end()) {
|
||||
CTxMemPoolModifiedEntry modEntry(desc);
|
||||
modEntry.nSizeWithAncestors -= it->GetTxSize();
|
||||
modEntry.discountSizeWithAncestors -= it->GetDiscountTxSize();
|
||||
modEntry.nModFeesWithAncestors -= it->GetModifiedFee();
|
||||
modEntry.nSigOpCostWithAncestors -= it->GetSigOpCost();
|
||||
mapModifiedTx.insert(modEntry);
|
||||
|
|
@ -367,7 +368,8 @@ void BlockAssembler::addPackageTxs(int& nPackagesSelected, int& nDescendantsUpda
|
|||
// and modifying them for their already included ancestors
|
||||
UpdatePackagesForAdded(inBlock, mapModifiedTx);
|
||||
|
||||
CTxMemPool::indexed_transaction_set::index<ancestor_score>::type::iterator mi = m_mempool.mapTx.get<ancestor_score>().begin();
|
||||
// ELEMENTS: we use confidential_score instead of ancestor_score
|
||||
CTxMemPool::indexed_transaction_set::index<confidential_score>::type::iterator mi = m_mempool.mapTx.get<confidential_score>().begin();
|
||||
CTxMemPool::txiter iter;
|
||||
|
||||
// Limit the number of attempts to add transactions to the block when it is
|
||||
|
|
@ -376,9 +378,9 @@ void BlockAssembler::addPackageTxs(int& nPackagesSelected, int& nDescendantsUpda
|
|||
const int64_t MAX_CONSECUTIVE_FAILURES = 1000;
|
||||
int64_t nConsecutiveFailed = 0;
|
||||
|
||||
while (mi != m_mempool.mapTx.get<ancestor_score>().end() || !mapModifiedTx.empty()) {
|
||||
while (mi != m_mempool.mapTx.get<confidential_score>().end() || !mapModifiedTx.empty()) {
|
||||
// First try to find a new transaction in mapTx to evaluate.
|
||||
if (mi != m_mempool.mapTx.get<ancestor_score>().end() &&
|
||||
if (mi != m_mempool.mapTx.get<confidential_score>().end() &&
|
||||
SkipMapTxEntry(m_mempool.mapTx.project<0>(mi), mapModifiedTx, failedTx)) {
|
||||
++mi;
|
||||
continue;
|
||||
|
|
@ -388,16 +390,16 @@ void BlockAssembler::addPackageTxs(int& nPackagesSelected, int& nDescendantsUpda
|
|||
// the next entry from mapTx, or the best from mapModifiedTx?
|
||||
bool fUsingModified = false;
|
||||
|
||||
modtxscoreiter modit = mapModifiedTx.get<ancestor_score>().begin();
|
||||
if (mi == m_mempool.mapTx.get<ancestor_score>().end()) {
|
||||
modconftxscoreiter modit = mapModifiedTx.get<confidential_score>().begin();
|
||||
if (mi == m_mempool.mapTx.get<confidential_score>().end()) {
|
||||
// We're out of entries in mapTx; use the entry from mapModifiedTx
|
||||
iter = modit->iter;
|
||||
fUsingModified = true;
|
||||
} else {
|
||||
// Try to compare the mapTx entry to the mapModifiedTx entry
|
||||
iter = m_mempool.mapTx.project<0>(mi);
|
||||
if (modit != mapModifiedTx.get<ancestor_score>().end() &&
|
||||
CompareTxMemPoolEntryByAncestorFee()(*modit, CTxMemPoolModifiedEntry(iter))) {
|
||||
if (modit != mapModifiedTx.get<confidential_score>().end() &&
|
||||
CompareTxMemPoolEntryByConfidentialFee()(*modit, CTxMemPoolModifiedEntry(iter))) {
|
||||
// The best entry in mapModifiedTx has higher score
|
||||
// than the one from mapTx.
|
||||
// Switch which transaction (package) to consider
|
||||
|
|
@ -439,7 +441,7 @@ void BlockAssembler::addPackageTxs(int& nPackagesSelected, int& nDescendantsUpda
|
|||
// Since we always look at the best entry in mapModifiedTx,
|
||||
// we must erase failed entries so that we can consider the
|
||||
// next best entry on the next loop iteration
|
||||
mapModifiedTx.get<ancestor_score>().erase(modit);
|
||||
mapModifiedTx.get<confidential_score>().erase(modit);
|
||||
failedTx.insert(iter);
|
||||
}
|
||||
|
||||
|
|
@ -464,7 +466,7 @@ void BlockAssembler::addPackageTxs(int& nPackagesSelected, int& nDescendantsUpda
|
|||
// Test if all tx's are Final
|
||||
if (!TestPackageTransactions(ancestors)) {
|
||||
if (fUsingModified) {
|
||||
mapModifiedTx.get<ancestor_score>().erase(modit);
|
||||
mapModifiedTx.get<confidential_score>().erase(modit);
|
||||
failedTx.insert(iter);
|
||||
}
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -41,18 +41,22 @@ struct CTxMemPoolModifiedEntry {
|
|||
{
|
||||
iter = entry;
|
||||
nSizeWithAncestors = entry->GetSizeWithAncestors();
|
||||
discountSizeWithAncestors = entry->GetDiscountSizeWithAncestors();
|
||||
nModFeesWithAncestors = entry->GetModFeesWithAncestors();
|
||||
nSigOpCostWithAncestors = entry->GetSigOpCostWithAncestors();
|
||||
}
|
||||
|
||||
CAmount GetModifiedFee() const { return iter->GetModifiedFee(); }
|
||||
uint64_t GetSizeWithAncestors() const { return nSizeWithAncestors; }
|
||||
uint64_t GetDiscountSizeWithAncestors() const { return discountSizeWithAncestors; }
|
||||
CAmount GetModFeesWithAncestors() const { return nModFeesWithAncestors; }
|
||||
size_t GetTxSize() const { return iter->GetTxSize(); }
|
||||
size_t GetDiscountTxSize() const { return iter->GetDiscountTxSize(); }
|
||||
const CTransaction& GetTx() const { return iter->GetTx(); }
|
||||
|
||||
CTxMemPool::txiter iter;
|
||||
uint64_t nSizeWithAncestors;
|
||||
uint64_t discountSizeWithAncestors;
|
||||
CAmount nModFeesWithAncestors;
|
||||
int64_t nSigOpCostWithAncestors;
|
||||
};
|
||||
|
|
@ -103,12 +107,19 @@ typedef boost::multi_index_container<
|
|||
boost::multi_index::tag<ancestor_score>,
|
||||
boost::multi_index::identity<CTxMemPoolModifiedEntry>,
|
||||
CompareTxMemPoolEntryByAncestorFee
|
||||
>,
|
||||
// ELEMENTS
|
||||
boost::multi_index::ordered_non_unique<
|
||||
boost::multi_index::tag<confidential_score>,
|
||||
boost::multi_index::identity<CTxMemPoolModifiedEntry>,
|
||||
CompareTxMemPoolEntryByConfidentialFee
|
||||
>
|
||||
>
|
||||
> indexed_modified_transaction_set;
|
||||
|
||||
typedef indexed_modified_transaction_set::nth_index<0>::type::iterator modtxiter;
|
||||
typedef indexed_modified_transaction_set::index<ancestor_score>::type::iterator modtxscoreiter;
|
||||
typedef indexed_modified_transaction_set::index<confidential_score>::type::iterator modconftxscoreiter; // ELEMENTS
|
||||
|
||||
struct update_for_parent_inclusion
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue