| 1126 | } |
| 1127 | |
| 1128 | bool 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 | |
| 1174 | bool MemPoolAccept::SubmitPackage(const ATMPArgs& args, std::vector<Workspace>& workspaces, |
| 1175 | PackageValidationState& package_state, |
no test coverage detected