Skip to content

Commit 2249300

Browse files
committed
Overhead calculation for propagation transfer limits
1 parent 7ecd3c0 commit 2249300

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

LXMF/LXMPeer.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,15 +163,16 @@ def sync(self):
163163
self.unhandled_messages.pop(transient_id)
164164

165165
unhandled_entries.sort(key=lambda e: e[1], reverse=False)
166-
cumulative_size = 0
166+
per_message_overhead = 16 # Really only 2 bytes, but set a bit higher for now
167+
cumulative_size = 24 # Initialised to highest reasonable binary structure overhead
167168
for unhandled_entry in unhandled_entries:
168169
transient_id = unhandled_entry[0]
169170
weight = unhandled_entry[1]
170171
lxm_size = unhandled_entry[2]
171172
if self.propagation_transfer_limit != None and cumulative_size + lxm_size > (self.propagation_transfer_limit*1000):
172173
pass
173174
else:
174-
cumulative_size += lxm_size
175+
cumulative_size += (lxm_size+per_message_overhead)
175176
unhandled_ids.append(transient_id)
176177

177178
RNS.log("Sending sync request to peer "+str(self.destination), RNS.LOG_DEBUG)

0 commit comments

Comments
 (0)