@@ -35,7 +35,7 @@ proc isAcknowledged*(
3535
3636proc reviewAckStatus (
3737 rm: ReliabilityManager , msg: SdsMessage
38- ): Future [ void ] {.async : (raises: [CatchableError ]), gcsafe .} =
38+ ) {.async : (raises: [CatchableError ]).} =
3939 try :
4040 var rbf: Option [RollingBloomFilter ]
4141 if msg.bloomFilter.len > 0 :
@@ -46,8 +46,10 @@ proc reviewAckStatus(
4646 RollingBloomFilter .init (
4747 filter = bf,
4848 capacity = bf.capacity,
49- minCapacity = (bf.capacity.float * (100 - CapacityFlexPercent ).float / 100.0 ).int ,
50- maxCapacity = (bf.capacity.float * (100 + CapacityFlexPercent ).float / 100.0 ).int ,
49+ minCapacity =
50+ (bf.capacity.float * (100 - CapacityFlexPercent ).float / 100.0 ).int ,
51+ maxCapacity =
52+ (bf.capacity.float * (100 + CapacityFlexPercent ).float / 100.0 ).int ,
5153 )
5254 )
5355 else :
@@ -167,7 +169,7 @@ proc wrapOutgoingMessage*(
167169
168170proc processIncomingBuffer (
169171 rm: ReliabilityManager , channelId: SdsChannelID
170- ): Future [ void ] {.async : (raises: [CatchableError ]), gcsafe .} =
172+ ) {.async : (raises: [CatchableError ]).} =
171173 try :
172174 await rm.lock.acquire ()
173175 try :
@@ -220,10 +222,12 @@ proc processIncomingBuffer(
220222
221223proc unwrapReceivedMessage * (
222224 rm: ReliabilityManager , message: seq [byte ]
223- ): Future [Result [
224- tuple [message: seq [byte ], missingDeps: seq [HistoryEntry ], channelId: SdsChannelID ],
225- ReliabilityError ,
226- ]] {.async : (raises: [CancelledError ]), gcsafe .} =
225+ ): Future [
226+ Result [
227+ tuple [message: seq [byte ], missingDeps: seq [HistoryEntry ], channelId: SdsChannelID ],
228+ ReliabilityError ,
229+ ]
230+ ] {.async : (raises: [CancelledError ]).} =
227231 # # Unwraps a received message and processes its reliability metadata.
228232 try :
229233 let channelId = extractChannelId (message).valueOr:
@@ -258,17 +262,18 @@ proc unwrapReceivedMessage*(
258262 # Remove from our own outgoing repair buffer (someone else is also requesting)
259263 channel.outgoingRepairBuffer.del (repairEntry.messageId)
260264 await rm.persistence.removeOutgoingRepair (channelId, repairEntry.messageId)
261- if repairEntry.messageId in channel.messageHistory and
262- rm.participantId.len > 0 and repairEntry.senderId.len > 0 :
265+ if repairEntry.messageId in channel.messageHistory and rm.participantId.len > 0 and
266+ repairEntry.senderId.len > 0 :
263267 if isInResponseGroup (
264- rm.participantId, repairEntry.senderId,
265- repairEntry.messageId, rm.config.numResponseGroups
268+ rm.participantId, repairEntry.senderId, repairEntry.messageId,
269+ rm.config.numResponseGroups,
266270 ):
267- let serialized = serializeMessage (channel.messageHistory[repairEntry.messageId])
271+ let serialized =
272+ serializeMessage (channel.messageHistory[repairEntry.messageId])
268273 if serialized.isOk ():
269274 let tResp = computeTResp (
270- rm.participantId, repairEntry.senderId,
271- repairEntry.messageId, rm.config.repairTMax
275+ rm.participantId, repairEntry.senderId, repairEntry.messageId,
276+ rm.config.repairTMax,
272277 )
273278 let inEntry = IncomingRepairEntry (
274279 inHistEntry: repairEntry,
@@ -302,15 +307,16 @@ proc unwrapReceivedMessage*(
302307 channel.incomingBuffer[pendingId].missingDeps.excl (msg.messageId)
303308 unblocked.add (pendingId)
304309 for pendingId in unblocked:
305- await rm.persistence.saveIncoming (channelId, channel.incomingBuffer[pendingId])
310+ await rm.persistence.saveIncoming (
311+ channelId, channel.incomingBuffer[pendingId]
312+ )
306313 await rm.processIncomingBuffer (channelId)
307314 if not rm.onMessageReady.isNil ():
308315 {.cast (raises: []).}:
309316 rm.onMessageReady (msg.messageId, channelId)
310317 else :
311318 let entry = IncomingMessage .init (
312- message = msg,
313- missingDeps = missingDeps.getMessageIds ().toHashSet (),
319+ message = msg, missingDeps = missingDeps.getMessageIds ().toHashSet ()
314320 )
315321 channel.incomingBuffer[msg.messageId] = entry
316322 await rm.persistence.saveIncoming (channelId, entry)
@@ -323,13 +329,11 @@ proc unwrapReceivedMessage*(
323329 for dep in missingDeps:
324330 if dep.messageId notin channel.outgoingRepairBuffer:
325331 let tReq = computeTReq (
326- rm.participantId, dep.messageId,
327- rm.config.repairTMin, rm.config.repairTMax
328- )
329- let outEntry = OutgoingRepairEntry (
330- outHistEntry: dep,
331- minTimeRepairReq: now + tReq,
332+ rm.participantId, dep.messageId, rm.config.repairTMin,
333+ rm.config.repairTMax,
332334 )
335+ let outEntry =
336+ OutgoingRepairEntry (outHistEntry: dep, minTimeRepairReq: now + tReq)
333337 channel.outgoingRepairBuffer[dep.messageId] = outEntry
334338 await rm.persistence.saveOutgoingRepair (channelId, dep.messageId, outEntry)
335339
@@ -342,7 +346,7 @@ proc unwrapReceivedMessage*(
342346
343347proc markDependenciesMet * (
344348 rm: ReliabilityManager , messageIds: seq [SdsMessageID ], channelId: SdsChannelID
345- ): Future [Result [void , ReliabilityError ]] {.async : (raises: [CancelledError ]), gcsafe .} =
349+ ): Future [Result [void , ReliabilityError ]] {.async : (raises: [CancelledError ]).} =
346350 # # Marks the specified message dependencies as met.
347351 try :
348352 if channelId notin rm.channels:
@@ -385,7 +389,7 @@ proc setCallbacks*(
385389 onPeriodicSync: PeriodicSyncCallback = nil ,
386390 onRetrievalHint: RetrievalHintProvider = nil ,
387391 onRepairReady: RepairReadyCallback = nil ,
388- ): Future [ void ] {.async : (raises: [CancelledError ]), gcsafe .} =
392+ ) {.async : (raises: [CancelledError ]).} =
389393 # # Sets the callback functions for various events in the ReliabilityManager.
390394 try :
391395 await rm.lock.acquire ()
@@ -405,7 +409,7 @@ proc setCallbacks*(
405409
406410proc checkUnacknowledgedMessages (
407411 rm: ReliabilityManager , channelId: SdsChannelID
408- ): Future [ void ] {.async : (raises: [CancelledError ]), gcsafe .} =
412+ ) {.async : (raises: [CancelledError ]).} =
409413 try :
410414 await rm.lock.acquire ()
411415 try :
@@ -443,9 +447,7 @@ proc checkUnacknowledgedMessages(
443447 error " Failed to check unacknowledged messages" ,
444448 channelId = channelId, msg = getCurrentExceptionMsg ()
445449
446- proc periodicBufferSweep (
447- rm: ReliabilityManager
448- ) {.async : (raises: [CancelledError ]), gcsafe .} =
450+ proc periodicBufferSweep (rm: ReliabilityManager ) {.async : (raises: [CancelledError ]).} =
449451 while true :
450452 try :
451453 for channelId, channel in rm.channels:
@@ -458,9 +460,7 @@ proc periodicBufferSweep(
458460
459461 await sleepAsync (chronos.milliseconds (rm.config.bufferSweepInterval.inMilliseconds))
460462
461- proc periodicSyncMessage (
462- rm: ReliabilityManager
463- ) {.async : (raises: [CancelledError ]), gcsafe .} =
463+ proc periodicSyncMessage (rm: ReliabilityManager ) {.async : (raises: [CancelledError ]).} =
464464 while true :
465465 try :
466466 if not rm.onPeriodicSync.isNil ():
@@ -470,9 +470,7 @@ proc periodicSyncMessage(
470470 error " Error in periodic sync" , msg = getCurrentExceptionMsg ()
471471 await sleepAsync (chronos.seconds (rm.config.syncMessageInterval.inSeconds))
472472
473- proc runRepairSweep * (
474- rm: ReliabilityManager
475- ): Future [void ] {.async : (raises: [CancelledError ]), gcsafe .} =
473+ proc runRepairSweep * (rm: ReliabilityManager ) {.async : (raises: [CancelledError ]).} =
476474 # # SDS-R: Runs a single pass of the repair sweep.
477475 # # - Incoming: fires onRepairReady for expired T_resp entries and removes them
478476 # # - Outgoing: drops entries past T_max window
@@ -518,9 +516,7 @@ proc runRepairSweep*(
518516 except CatchableError :
519517 error " Error in repair sweep" , msg = getCurrentExceptionMsg ()
520518
521- proc periodicRepairSweep (
522- rm: ReliabilityManager
523- ) {.async : (raises: [CancelledError ]), gcsafe .} =
519+ proc periodicRepairSweep (rm: ReliabilityManager ) {.async : (raises: [CancelledError ]).} =
524520 # # SDS-R: Periodically checks repair buffers for expired entries.
525521 while true :
526522 await rm.runRepairSweep ()
@@ -537,7 +533,7 @@ proc startPeriodicTasks*(rm: ReliabilityManager) =
537533
538534proc resetReliabilityManager * (
539535 rm: ReliabilityManager
540- ): Future [Result [void , ReliabilityError ]] {.async : (raises: [CancelledError ]), gcsafe .} =
536+ ): Future [Result [void , ReliabilityError ]] {.async : (raises: [CancelledError ]).} =
541537 # # Resets the ReliabilityManager to its initial state.
542538 try :
543539 await rm.lock.acquire ()
0 commit comments