Skip to content

Commit 0fb17bf

Browse files
committed
[log] updates in TxOrphanage
- Add elapsed time in "remove orphan" log - Add size in "stored orphan" log - grammar edit
1 parent b16da7e commit 0fb17bf

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/txorphanage.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ bool TxOrphanage::AddTx(const CTransactionRef& tx, NodeId peer)
4747
m_outpoint_to_orphan_it[txin.prevout].insert(ret.first);
4848
}
4949

50-
LogPrint(BCLog::TXPACKAGES, "stored orphan tx %s (wtxid=%s) (mapsz %u outsz %u)\n", hash.ToString(), wtxid.ToString(),
50+
LogPrint(BCLog::TXPACKAGES, "stored orphan tx %s (wtxid=%s), weight: %u (mapsz %u outsz %u)\n", hash.ToString(), wtxid.ToString(), sz,
5151
m_orphans.size(), m_outpoint_to_orphan_it.size());
5252
return true;
5353
}
@@ -84,7 +84,10 @@ int TxOrphanage::EraseTxNoLock(const Wtxid& wtxid)
8484
it_last->second.list_pos = old_pos;
8585
}
8686
const auto& txid = it->second.tx->GetHash();
87-
LogPrint(BCLog::TXPACKAGES, " removed orphan tx %s (wtxid=%s)\n", txid.ToString(), wtxid.ToString());
87+
// Time spent in orphanage = difference between current and entry time.
88+
// Entry time is equal to ORPHAN_TX_EXPIRE_TIME earlier than entry's expiry.
89+
LogPrint(BCLog::TXPACKAGES, " removed orphan tx %s (wtxid=%s) after %ds\n", txid.ToString(), wtxid.ToString(),
90+
GetTime() + ORPHAN_TX_EXPIRE_TIME - it->second.nTimeExpire);
8891
m_orphan_list.pop_back();
8992

9093
m_orphans.erase(it);
@@ -107,7 +110,7 @@ void TxOrphanage::EraseForPeer(NodeId peer)
107110
nErased += EraseTxNoLock(wtxid);
108111
}
109112
}
110-
if (nErased > 0) LogPrint(BCLog::TXPACKAGES, "Erased %d orphan tx from peer=%d\n", nErased, peer);
113+
if (nErased > 0) LogPrint(BCLog::TXPACKAGES, "Erased %d orphan transaction(s) from peer=%d\n", nErased, peer);
111114
}
112115

113116
void TxOrphanage::LimitOrphans(unsigned int max_orphans, FastRandomContext& rng)
@@ -230,7 +233,7 @@ void TxOrphanage::EraseForBlock(const CBlock& block)
230233
for (const auto& orphanHash : vOrphanErase) {
231234
nErased += EraseTxNoLock(orphanHash);
232235
}
233-
LogPrint(BCLog::TXPACKAGES, "Erased %d orphan tx included or conflicted by block\n", nErased);
236+
LogPrint(BCLog::TXPACKAGES, "Erased %d orphan transaction(s) included or conflicted by block\n", nErased);
234237
}
235238
}
236239

test/functional/p2p_invalid_tx.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def run_test(self):
165165
node.p2ps[0].send_txs_and_test([rejected_parent], node, success=False)
166166

167167
self.log.info('Test that a peer disconnection causes erase its transactions from the orphan pool')
168-
with node.assert_debug_log(['Erased 100 orphan tx from peer=25']):
168+
with node.assert_debug_log(['Erased 100 orphan transaction(s) from peer=25']):
169169
self.reconnect_p2p(num_connections=1)
170170

171171
self.log.info('Test that a transaction in the orphan pool is included in a new tip block causes erase this transaction from the orphan pool')
@@ -190,7 +190,7 @@ def run_test(self):
190190
block_A.solve()
191191

192192
self.log.info('Send the block that includes the previous orphan ... ')
193-
with node.assert_debug_log(["Erased 1 orphan tx included or conflicted by block"]):
193+
with node.assert_debug_log(["Erased 1 orphan transaction(s) included or conflicted by block"]):
194194
node.p2ps[0].send_blocks_and_test([block_A], node, success=True)
195195

196196
self.log.info('Test that a transaction in the orphan pool conflicts with a new tip block causes erase this transaction from the orphan pool')
@@ -219,7 +219,7 @@ def run_test(self):
219219
block_B.solve()
220220

221221
self.log.info('Send the block that includes a transaction which conflicts with the previous orphan ... ')
222-
with node.assert_debug_log(["Erased 1 orphan tx included or conflicted by block"]):
222+
with node.assert_debug_log(["Erased 1 orphan transaction(s) included or conflicted by block"]):
223223
node.p2ps[0].send_blocks_and_test([block_B], node, success=True)
224224

225225

0 commit comments

Comments
 (0)