explain the `<` usage

This commit is contained in:
Etan Kissling 2024-03-27 23:30:36 +01:00
parent 40242ac277
commit 5fb293c595
No known key found for this signature in database
GPG Key ID: B21DA824C5A3D03D
1 changed files with 2 additions and 1 deletions

View File

@ -502,7 +502,8 @@ proc acquireItemImpl[A, B](pool: PeerPool[A, B],
let pindex = let pindex =
if filter == {PeerType.Incoming, PeerType.Outgoing}: if filter == {PeerType.Incoming, PeerType.Outgoing}:
if len(pool.outQueue) > 0 and len(pool.incQueue) > 0: 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]: if pool.incQueue[0] < pool.outQueue[0]:
inc(pool.acqIncPeersCount) inc(pool.acqIncPeersCount)
let item = pool.incQueue.pop() let item = pool.incQueue.pop()