From b451cb8dbc38ee9532f7c33bce3abc22d4f944ff Mon Sep 17 00:00:00 2001 From: nblagoev Date: Mon, 29 Apr 2024 19:17:41 +0300 Subject: [PATCH] ignore size in delayer --- deccom/protocols/delayprotocol.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/deccom/protocols/delayprotocol.py b/deccom/protocols/delayprotocol.py index 0e4e214..d556903 100644 --- a/deccom/protocols/delayprotocol.py +++ b/deccom/protocols/delayprotocol.py @@ -14,15 +14,16 @@ def __init__(self, delay_map, submodule=None, callback: Callable[[tuple[str, int #self.stream_callback(data,node_id,addr) - async def send_stream(self,node_id,data): + async def send_stream(self,node_id,data, ignore_sz = 0): print("delay...") p = self.get_peer(node_id) print(p) loop = asyncio.get_event_loop() dl = self.delay_map(p.pub_key, self.peer.pub_key) + sz = len(data) - ignore_sz print(dl) - print("will send in ",dl[0]/1000 + len(data)/(1024**3*dl[1])) - await asyncio.sleep(dl[0]/1000 + len(data)/(1024**3*dl[1])) + print("will send in ",dl[0]/1000 + sz/(1024**3*dl[1])) + await asyncio.sleep(dl[0]/1000 + sz/(1024**3*dl[1])) if self.started: return await self._lower_send_to(node_id,data) @bindto("send_stream")