Skip to content

Commit b50bd72

Browse files
committed
[prep] change return type of EraseTx to bool
This function only ever returns 0 or 1 (number of unique orphans erased).
1 parent 3da6d7f commit b50bd72

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

src/node/txdownloadman_impl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ node::RejectedTxTodo TxDownloadManagerImpl::MempoolRejectedTx(const CTransaction
491491

492492
// If the tx failed in ProcessOrphanTx, it should be removed from the orphanage unless the
493493
// tx was still missing inputs. If the tx was not in the orphanage, EraseTx does nothing and returns 0.
494-
if (state.GetResult() != TxValidationResult::TX_MISSING_INPUTS && m_orphanage->EraseTx(ptx->GetWitnessHash()) > 0) {
494+
if (state.GetResult() != TxValidationResult::TX_MISSING_INPUTS && m_orphanage->EraseTx(ptx->GetWitnessHash())) {
495495
LogDebug(BCLog::TXPACKAGES, " removed orphan tx %s (wtxid=%s)\n", ptx->GetHash().ToString(), ptx->GetWitnessHash().ToString());
496496
}
497497

src/node/txorphanage.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class TxOrphanageImpl final : public TxOrphanage {
7676
bool HaveTx(const Wtxid& wtxid) const override;
7777
bool HaveTxFromPeer(const Wtxid& wtxid, NodeId peer) const override;
7878
CTransactionRef GetTxToReconsider(NodeId peer) override;
79-
int EraseTx(const Wtxid& wtxid) override;
79+
bool EraseTx(const Wtxid& wtxid) override;
8080
void EraseForPeer(NodeId peer) override;
8181
void EraseForBlock(const CBlock& block) override;
8282
void LimitOrphans(FastRandomContext& rng) override;
@@ -147,11 +147,11 @@ bool TxOrphanageImpl::AddAnnouncer(const Wtxid& wtxid, NodeId peer)
147147
return false;
148148
}
149149

150-
int TxOrphanageImpl::EraseTx(const Wtxid& wtxid)
150+
bool TxOrphanageImpl::EraseTx(const Wtxid& wtxid)
151151
{
152152
std::map<Wtxid, OrphanTx>::iterator it = m_orphans.find(wtxid);
153153
if (it == m_orphans.end())
154-
return 0;
154+
return false;
155155
for (const CTxIn& txin : it->second.tx->vin)
156156
{
157157
auto itPrev = m_outpoint_to_orphan_it.find(txin.prevout);
@@ -190,7 +190,7 @@ int TxOrphanageImpl::EraseTx(const Wtxid& wtxid)
190190
m_orphan_list.pop_back();
191191

192192
m_orphans.erase(it);
193-
return 1;
193+
return true;
194194
}
195195

196196
void TxOrphanageImpl::EraseForPeer(NodeId peer)

src/node/txorphanage.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,9 @@ class TxOrphanage {
6767
*/
6868
virtual CTransactionRef GetTxToReconsider(NodeId peer) = 0;
6969

70-
/** Erase an orphan by wtxid */
71-
virtual int EraseTx(const Wtxid& wtxid) = 0;
70+
/** Erase an orphan by wtxid, including all announcements if there are multiple.
71+
* Returns true if an orphan was erased, false if no tx with this wtxid exists. */
72+
virtual bool EraseTx(const Wtxid& wtxid) = 0;
7273

7374
/** Maybe erase all orphans announced by a peer (eg, after that peer disconnects). If an orphan
7475
* has been announced by another peer, don't erase, just remove this peer from the list of announcers. */

0 commit comments

Comments
 (0)