From d145b4c138a1134059e05b3be8961648c4c4a1a9 Mon Sep 17 00:00:00 2001 From: Ivan FB Date: Tue, 2 Jun 2026 14:14:26 +0200 Subject: [PATCH] add comment to explain better tryFinalizeChannelReq --- channels/reliable_channel.nim | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/channels/reliable_channel.nim b/channels/reliable_channel.nim index b68cfbfab..e32b57e36 100644 --- a/channels/reliable_channel.nim +++ b/channels/reliable_channel.nim @@ -125,6 +125,12 @@ func getSenderId*(self: ReliableChannel): SdsParticipantID {.inline.} = self.senderId proc tryFinalizeChannelReq(self: ReliableChannel, channelReqId: RequestId) = + ## Tries to finalize the channel-level request identified by `channelReqId` if + ## certain conditions are met, i.e., no segments are still awaiting dispatch or in flight, + ## and the total number of confirmed + failed segments equals the total expected segments. + ## Therefore, the channel-level request is removed from `self.channelReqs` + ## and the appropriate final event is emitted. + ## let state = self.channelReqs.getOrDefault(channelReqId) if state.totalExpectedSegments == 0: ## Either already finalized (and removed) or never inserted.