From 5fb293c595ac9115f716d017d17ba0fc8fbff20b Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Wed, 27 Mar 2024 23:30:36 +0100 Subject: [PATCH] explain the `<` usage --- beacon_chain/networking/peer_pool.nim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/beacon_chain/networking/peer_pool.nim b/beacon_chain/networking/peer_pool.nim index cc21f05e1..90c807e25 100644 --- a/beacon_chain/networking/peer_pool.nim +++ b/beacon_chain/networking/peer_pool.nim @@ -502,7 +502,8 @@ proc acquireItemImpl[A, B](pool: PeerPool[A, B], let pindex = if filter == {PeerType.Incoming, PeerType.Outgoing}: if len(pool.outQueue) > 0 and len(pool.incQueue) > 0: - # Don't think `<` is actually `<` here. + # `<` here is the `PeerIndex` implementation (`HeapQueue` uses `<`), + # which then flips the arguments to rank `>` on `A` using `pool.cmp` if pool.incQueue[0] < pool.outQueue[0]: inc(pool.acqIncPeersCount) let item = pool.incQueue.pop()