mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-08-30 18:01:04 +02:00
[prep] change return type of EraseTx to bool
This function only ever returns 0 or 1 (number of unique orphans erased).
This commit is contained in:
@@ -491,7 +491,7 @@ node::RejectedTxTodo TxDownloadManagerImpl::MempoolRejectedTx(const CTransaction
|
||||
|
||||
// If the tx failed in ProcessOrphanTx, it should be removed from the orphanage unless the
|
||||
// tx was still missing inputs. If the tx was not in the orphanage, EraseTx does nothing and returns 0.
|
||||
if (state.GetResult() != TxValidationResult::TX_MISSING_INPUTS && m_orphanage->EraseTx(ptx->GetWitnessHash()) > 0) {
|
||||
if (state.GetResult() != TxValidationResult::TX_MISSING_INPUTS && m_orphanage->EraseTx(ptx->GetWitnessHash())) {
|
||||
LogDebug(BCLog::TXPACKAGES, " removed orphan tx %s (wtxid=%s)\n", ptx->GetHash().ToString(), ptx->GetWitnessHash().ToString());
|
||||
}
|
||||
|
||||
|
@@ -76,7 +76,7 @@ public:
|
||||
bool HaveTx(const Wtxid& wtxid) const override;
|
||||
bool HaveTxFromPeer(const Wtxid& wtxid, NodeId peer) const override;
|
||||
CTransactionRef GetTxToReconsider(NodeId peer) override;
|
||||
int EraseTx(const Wtxid& wtxid) override;
|
||||
bool EraseTx(const Wtxid& wtxid) override;
|
||||
void EraseForPeer(NodeId peer) override;
|
||||
void EraseForBlock(const CBlock& block) override;
|
||||
void LimitOrphans(FastRandomContext& rng) override;
|
||||
@@ -147,11 +147,11 @@ bool TxOrphanageImpl::AddAnnouncer(const Wtxid& wtxid, NodeId peer)
|
||||
return false;
|
||||
}
|
||||
|
||||
int TxOrphanageImpl::EraseTx(const Wtxid& wtxid)
|
||||
bool TxOrphanageImpl::EraseTx(const Wtxid& wtxid)
|
||||
{
|
||||
std::map<Wtxid, OrphanTx>::iterator it = m_orphans.find(wtxid);
|
||||
if (it == m_orphans.end())
|
||||
return 0;
|
||||
return false;
|
||||
for (const CTxIn& txin : it->second.tx->vin)
|
||||
{
|
||||
auto itPrev = m_outpoint_to_orphan_it.find(txin.prevout);
|
||||
@@ -190,7 +190,7 @@ int TxOrphanageImpl::EraseTx(const Wtxid& wtxid)
|
||||
m_orphan_list.pop_back();
|
||||
|
||||
m_orphans.erase(it);
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
void TxOrphanageImpl::EraseForPeer(NodeId peer)
|
||||
|
@@ -67,8 +67,9 @@ public:
|
||||
*/
|
||||
virtual CTransactionRef GetTxToReconsider(NodeId peer) = 0;
|
||||
|
||||
/** Erase an orphan by wtxid */
|
||||
virtual int EraseTx(const Wtxid& wtxid) = 0;
|
||||
/** Erase an orphan by wtxid, including all announcements if there are multiple.
|
||||
* Returns true if an orphan was erased, false if no tx with this wtxid exists. */
|
||||
virtual bool EraseTx(const Wtxid& wtxid) = 0;
|
||||
|
||||
/** Maybe erase all orphans announced by a peer (eg, after that peer disconnects). If an orphan
|
||||
* has been announced by another peer, don't erase, just remove this peer from the list of announcers. */
|
||||
|
Reference in New Issue
Block a user