MCPcopy Create free account
hub / github.com/ElementsProject/elements / Finalize

Method Finalize

src/validation.cpp:1128–1172  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1126}
1127
1128bool MemPoolAccept::Finalize(const ATMPArgs& args, Workspace& ws)
1129{
1130 AssertLockHeld(cs_main);
1131 AssertLockHeld(m_pool.cs);
1132 const CTransaction& tx = *ws.m_ptx;
1133 const uint256& hash = ws.m_hash;
1134 TxValidationState& state = ws.m_state;
1135 const bool bypass_limits = args.m_bypass_limits;
1136
1137 std::unique_ptr<CTxMemPoolEntry>& entry = ws.m_entry;
1138
1139 // Remove conflicting transactions from the mempool
1140 for (CTxMemPool::txiter it : ws.m_all_conflicting)
1141 {
1142 LogPrint(BCLog::MEMPOOL, "replacing tx %s with %s for %s additional fees, %d delta bytes\n",
1143 it->GetTx().GetHash().ToString(),
1144 hash.ToString(),
1145 FormatMoney(ws.m_modified_fees - ws.m_conflicting_fees),
1146 (int)entry->GetTxSize() - (int)ws.m_conflicting_size);
1147 ws.m_replaced_transactions.push_back(it->GetSharedTx());
1148 }
1149 m_pool.RemoveStaged(ws.m_all_conflicting, false, MemPoolRemovalReason::REPLACED);
1150
1151 // This transaction should only count for fee estimation if:
1152 // - it's not being re-added during a reorg which bypasses typical mempool fee limits
1153 // - the node is not behind
1154 // - the transaction is not dependent on any other transactions in the mempool
1155 // - it's not part of a package. Since package relay is not currently supported, this
1156 // transaction has not necessarily been accepted to miners' mempools.
1157 bool validForFeeEstimation = !bypass_limits && !args.m_package_submission && IsCurrentForFeeEstimation(m_active_chainstate) && m_pool.HasNoInputsOf(tx);
1158
1159 // Store transaction in memory
1160 m_pool.addUnchecked(*entry, ws.m_ancestors, validForFeeEstimation);
1161
1162 // trim mempool and check if tx was trimmed
1163 // If we are validating a package, don't trim here because we could evict a previous transaction
1164 // in the package. LimitMempoolSize() should be called at the very end to make sure the mempool
1165 // is still within limits and package submission happens atomically.
1166 if (!args.m_package_submission && !bypass_limits) {
1167 LimitMempoolSize(m_pool, m_active_chainstate.CoinsTip(), gArgs.GetIntArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000, std::chrono::hours{gArgs.GetIntArg("-mempoolexpiry", DEFAULT_MEMPOOL_EXPIRY)});
1168 if (!m_pool.exists(GenTxid::Txid(hash)))
1169 return state.Invalid(TxValidationResult::TX_MEMPOOL_POLICY, "mempool full");
1170 }
1171 return true;
1172}
1173
1174bool MemPoolAccept::SubmitPackage(const ATMPArgs& args, std::vector<Workspace>& workspaces,
1175 PackageValidationState& package_state,

Callers 15

DestBinToAddrFunction · 0.45
StrengthenFunction · 0.45
SeedEventsMethod · 0.45
MixExtractMethod · 0.45
calculate_contractFunction · 0.45
multiUserAuthorizedFunction · 0.45
operator()Method · 0.45
ComputeResponseFunction · 0.45
RelayAddressMethod · 0.45
BIP32HashFunction · 0.45
SHA256Uint256Function · 0.45

Calls 13

FormatMoneyFunction · 0.85
GetTxMethod · 0.80
GetSharedTxMethod · 0.80
RemoveStagedMethod · 0.80
HasNoInputsOfMethod · 0.80
addUncheckedMethod · 0.80
GetIntArgMethod · 0.80
InvalidMethod · 0.80
ToStringMethod · 0.45
GetHashMethod · 0.45
GetTxSizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected