From cb9071b478ff54daae210f91796c19b8a54da129 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Thu, 27 Aug 2026 01:56:43 +0200 Subject: [PATCH] Added HWM limit option to TransmitBuffer --- RNS/Interfaces/util/TransmitBuffer.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/RNS/Interfaces/util/TransmitBuffer.py b/RNS/Interfaces/util/TransmitBuffer.py index df6dce8d..42ab9942 100644 --- a/RNS/Interfaces/util/TransmitBuffer.py +++ b/RNS/Interfaces/util/TransmitBuffer.py @@ -63,8 +63,10 @@ class TransmitBuffer: # Queue a finalized and complete on-wire frame. # Executed by producer side only. - def append(self, frame): + def append(self, frame, limit=None): with self._tail_lock: + if limit is not None and (self._tx_total - self._tx_sent) + len(frame) > limit: return False + # Allocate separate chunks to frames # larger than the coalescing target. if len(frame) >= self.COALESCE_TARGET: @@ -91,6 +93,8 @@ class TransmitBuffer: # sparse traffic does not incur coalescing latency. self._flush() + return True + def _flush(self): if self._cur is not None and len(self._cur) > 0: self._chunks.append((self._cur, self._cur_frames))