From c3c04e84df907c165ef0ea3da91e733d67925080 Mon Sep 17 00:00:00 2001 From: Ben Date: Mon, 9 Dec 2024 09:14:49 +0100 Subject: [PATCH] Marks cancel-presence situation with todo comment. --- codex/blockexchange/engine/engine.nim | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/codex/blockexchange/engine/engine.nim b/codex/blockexchange/engine/engine.nim index 394fdf7e..a110ae62 100644 --- a/codex/blockexchange/engine/engine.nim +++ b/codex/blockexchange/engine/engine.nim @@ -412,8 +412,15 @@ proc wantListHandler*( if not e.cancel: peerCtx.peerWants.add(e) + # Important TODO! (See https://github.com/codex-storage/nim-codex/pull/1019#issuecomment-2525089803 ) + # The if type==WantHave (below) is NOT nested behind the if not cancel (above) on purpose! + # This means we send presence-lists in response to cancel messages. + # Not doing so will degrade the performance by more than an order of magnitude. + # TODO: Investigate WHY the presence list has such a performance impact. + # (Sending a presence-list in response to a cancel is not according to spec and should be removed + # once the performance impact mystery is understood and solved.) if e.wantType == WantType.WantHave: - # does this happen for cancels?! + # Respond to wantHaves immediately. let have = await e.address in b.localStore price = @(