@@ -51,7 +51,7 @@ class TxOrphanageImpl final : public TxOrphanage {
5151
5252 /* * Get an approximation for "memory usage". The total memory is a function of the memory used to store the
5353 * transaction itself, each entry in m_orphans, and each entry in m_outpoint_to_orphan_wtxids. We use weight because
54- * it is often higher than the actual memory usage of the tranaction . This metric conveniently encompasses
54+ * it is often higher than the actual memory usage of the transaction . This metric conveniently encompasses
5555 * m_outpoint_to_orphan_wtxids usage since input data does not get the witness discount, and makes it easier to
5656 * reason about each peer's limits using well-understood transaction attributes. */
5757 TxOrphanage::Usage GetMemUsage () const {
@@ -158,13 +158,13 @@ class TxOrphanageImpl final : public TxOrphanage {
158158 * do not trim unless the orphanage exceeds global limits, but it means that this peer will
159159 * be selected for trimming sooner. If the global latency score or global memory usage
160160 * limits are exceeded, it must be that there is a peer whose DoS score > 1. */
161- FeeFrac GetDosScore (TxOrphanage::Count max_peer_latency_score, TxOrphanage::Usage max_peer_bytes ) const
161+ FeeFrac GetDosScore (TxOrphanage::Count max_peer_latency_score, TxOrphanage::Usage max_peer_memory ) const
162162 {
163163 assert (max_peer_latency_score > 0 );
164- assert (max_peer_bytes > 0 );
165- const FeeFrac cpu_score (m_total_latency_score, max_peer_latency_score);
166- const FeeFrac mem_score (m_total_usage, max_peer_bytes );
167- return std::max<FeeFrac>(cpu_score , mem_score);
164+ assert (max_peer_memory > 0 );
165+ const FeeFrac latency_score (m_total_latency_score, max_peer_latency_score);
166+ const FeeFrac mem_score (m_total_usage, max_peer_memory );
167+ return std::max<FeeFrac>(latency_score , mem_score);
168168 }
169169 };
170170 /* * Store per-peer statistics. Used to determine each peer's DoS score. The size of this map is used to determine the
@@ -205,7 +205,7 @@ class TxOrphanageImpl final : public TxOrphanage {
205205 TxOrphanage::Count TotalLatencyScore () const override ;
206206 TxOrphanage::Usage ReservedPeerUsage () const override ;
207207
208- /* * Maximum allowed (deduplicated) latency score for all tranactions (see Announcement::GetLatencyScore()). Dynamic
208+ /* * Maximum allowed (deduplicated) latency score for all transactions (see Announcement::GetLatencyScore()). Dynamic
209209 * based on number of peers. Each peer has an equal amount, but the global maximum latency score stays constant. The
210210 * number of peers times MaxPeerLatencyScore() (rounded) adds up to MaxGlobalLatencyScore(). As long as every peer's
211211 * m_total_latency_score / MaxPeerLatencyScore() < 1, MaxGlobalLatencyScore() is not exceeded. */
@@ -469,11 +469,11 @@ void TxOrphanageImpl::LimitOrphans()
469469 std::make_heap (heap_peer_dos.begin (), heap_peer_dos.end (), compare_score);
470470
471471 unsigned int num_erased{0 };
472- // This outer loop finds the peer with the highest DoS score, which is a fraction of {usage, announcements} used
472+ // This outer loop finds the peer with the highest DoS score, which is a fraction of memory and latency scores
473473 // over the respective allowances. We continue until the orphanage is within global limits. That means some peers
474474 // might still have a DoS score > 1 at the end.
475- // Note: if ratios are the same, FeeFrac tiebreaks by denominator. In practice, since the CPU denominator (number of
476- // announcements) is always lower, this means that a peer with only high number of announcements will be targeted
475+ // Note: if ratios are the same, FeeFrac tiebreaks by denominator. In practice, since the latency denominator (number of
476+ // announcements and inputs ) is always lower, this means that a peer with only high latency scores will be targeted
477477 // before a peer using a lot of memory, even if they have the same ratios.
478478 do {
479479 Assume (!heap_peer_dos.empty ());
@@ -640,8 +640,6 @@ void TxOrphanageImpl::EraseForBlock(const CBlock& block)
640640 LimitOrphans ();
641641}
642642
643- /* * Get all children that spend from this tx and were received from nodeid. Sorted from most
644- * recent to least recent. */
645643std::vector<CTransactionRef> TxOrphanageImpl::GetChildrenFromSamePeer (const CTransactionRef& parent, NodeId peer) const
646644{
647645 std::vector<CTransactionRef> children_found;
0 commit comments