| 4276 | } |
| 4277 | |
| 4278 | void PeerManagerImpl::ProcessInvalidTx(NodeId nodeid, |
| 4279 | const CTransactionRef &ptx, |
| 4280 | const TxValidationState &state, |
| 4281 | bool maybe_add_extra_compact_tx) { |
| 4282 | AssertLockNotHeld(m_peer_mutex); |
| 4283 | AssertLockHeld(g_msgproc_mutex); |
| 4284 | AssertLockHeld(cs_main); |
| 4285 | |
| 4286 | const TxId &txid = ptx->GetId(); |
| 4287 | |
| 4288 | LogPrint(BCLog::MEMPOOLREJ, "%s from peer=%d was not accepted: %s\n", |
| 4289 | txid.ToString(), nodeid, state.ToString()); |
| 4290 | |
| 4291 | if (state.GetResult() == TxValidationResult::TX_MISSING_INPUTS) { |
| 4292 | return; |
| 4293 | } |
| 4294 | |
| 4295 | if (m_avalanche && |
| 4296 | m_avalanche->isPreconsensusActivated(m_chainman.ActiveTip()) && |
| 4297 | state.GetResult() == TxValidationResult::TX_AVALANCHE_RECONSIDERABLE) { |
| 4298 | return; |
| 4299 | } |
| 4300 | |
| 4301 | if (state.GetResult() == TxValidationResult::TX_PACKAGE_RECONSIDERABLE) { |
| 4302 | // If the result is TX_PACKAGE_RECONSIDERABLE, add it to |
| 4303 | // m_recent_rejects_package_reconsiderable because we should not |
| 4304 | // download or submit this transaction by itself again, but may submit |
| 4305 | // it as part of a package later. |
| 4306 | m_recent_rejects_package_reconsiderable.insert(txid); |
| 4307 | } else { |
| 4308 | m_recent_rejects.insert(txid); |
| 4309 | } |
| 4310 | m_txrequest.ForgetInvId(txid); |
| 4311 | |
| 4312 | if (maybe_add_extra_compact_tx && RecursiveDynamicUsage(*ptx) < 100000) { |
| 4313 | AddToCompactExtraTransactions(ptx); |
| 4314 | } |
| 4315 | |
| 4316 | MaybePunishNodeForTx(nodeid, state); |
| 4317 | |
| 4318 | // If the tx failed in ProcessOrphanTx, it should be removed from the |
| 4319 | // orphanage unless the tx was still missing inputs. If the tx was not in |
| 4320 | // the orphanage, EraseTx does nothing and returns 0. |
| 4321 | if (m_mempool.withOrphanage([&txid](TxOrphanage &orphanage) { |
| 4322 | return orphanage.EraseTx(txid); |
| 4323 | }) > 0) { |
| 4324 | LogPrint(BCLog::TXPACKAGES, " removed orphan tx %s\n", |
| 4325 | txid.ToString()); |
| 4326 | } |
| 4327 | } |
| 4328 | |
| 4329 | void PeerManagerImpl::ProcessValidTx(NodeId nodeid, const CTransactionRef &tx) { |
| 4330 | AssertLockNotHeld(m_peer_mutex); |
nothing calls this directly
no test coverage detected