Skip to content

Commit f6d1f14

Browse files
committed
chore: improve proc naming
1 parent 91d3d37 commit f6d1f14

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

libp2p/protocols/kademlia/find.nim

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ type Attempt = object
384384
## its ``timeout`` elapsed; the slot is freed but the RPC
385385
## keeps running so it can still deliver, and its late result is ignored.
386386

387-
proc runDispatch(
387+
proc dispatchPeer(
388388
kad: KadDHT, peerId: PeerId, target: Key, dispatch: DispatchProc
389389
): Future[DispatchResult] {.async: (raises: [CancelledError]).} =
390390
let res = await dispatch(kad, peerId, target)
@@ -400,7 +400,7 @@ func activePeers(pending: seq[Attempt]): HashSet[PeerId] {.raises: [].} =
400400
peers.incl(a.peer)
401401
peers
402402

403-
proc refill(
403+
proc fillSlots(
404404
kad: KadDHT, state: LookupState, pending: var seq[Attempt], dispatch: DispatchProc
405405
) {.raises: [].} =
406406
## Keep up to ``alpha`` RPCs in flight by dispatching the next-closest
@@ -417,7 +417,7 @@ proc refill(
417417
pending.add(
418418
Attempt(
419419
peer: peerId,
420-
fut: kad.runDispatch(peerId, target, dispatch),
420+
fut: kad.dispatchPeer(peerId, target, dispatch),
421421
deadline: Moment.now() + kad.config.timeout,
422422
abandoned: false,
423423
)
@@ -448,7 +448,7 @@ proc awaitProgress(pending: seq[Attempt]) {.async: (raises: [CancelledError]).}
448448
except ValueError:
449449
raiseAssert "race() cannot raise ValueError on a non-empty future list"
450450

451-
proc reapFinished(
451+
proc harvestInflight(
452452
pending: var seq[Attempt], now: Moment
453453
): seq[DispatchResult] {.raises: [].} =
454454
## Collect the replies of finished, still-relevant RPCs and drop them, and
@@ -526,14 +526,14 @@ proc iterativeLookup*(
526526
await pending.mapIt(it.fut).cancelAndWait()
527527

528528
while true:
529-
let completed = pending.reapFinished(Moment.now())
529+
let completed = pending.harvestInflight(Moment.now())
530530
await kad.applyReplies(state, rtable, completed, onReply)
531531
await state.dropDonePeers(pending).cancelAndWait()
532532

533533
# Once the stop condition holds, dispatch no new peers but keep draining the
534534
# replies already in flight, so the returned peer set stays complete.
535535
if not stopCond(state):
536-
kad.refill(state, pending, dispatch)
536+
kad.fillSlots(state, pending, dispatch)
537537

538538
if pending.activePeers().len == 0:
539539
break

0 commit comments

Comments
 (0)