From 9f5905382552ac785f48dcf172d6e0efed58ba84 Mon Sep 17 00:00:00 2001 From: nblagoev Date: Thu, 18 Apr 2024 13:07:01 +0300 Subject: [PATCH] bugman fixes --- deccom/nodes/node.py | 4 ++-- deccom/protocols/delayprotocol.py | 4 ++-- deccom/protocols/streamprotocol.py | 1 - 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/deccom/nodes/node.py b/deccom/nodes/node.py index 0d703dc..a9a668c 100644 --- a/deccom/nodes/node.py +++ b/deccom/nodes/node.py @@ -22,8 +22,8 @@ def __init__(self, p: Peer, protocol: AbstractProtocol, ip_addr = "0.0.0.0", por async def listen(self): loop = asyncio.get_running_loop() - listen = loop.create_datagram_endpoint(self.protocol_type.get_lowest, local_addr=(self.ip_addr, self.port)) - self.transport, self.protocol = await listen + self.udp = loop.create_datagram_endpoint(self.protocol_type.get_lowest, local_addr=(self.ip_addr, self.port)) + self.transport, self.protocol = await self.udp await self.protocol_type.start(self.peer) async def sendto(self, msg, addr): await self.protocol_type.sendto(msg, addr=addr) diff --git a/deccom/protocols/delayprotocol.py b/deccom/protocols/delayprotocol.py index fc80c11..0e4e214 100644 --- a/deccom/protocols/delayprotocol.py +++ b/deccom/protocols/delayprotocol.py @@ -21,8 +21,8 @@ async def send_stream(self,node_id,data): loop = asyncio.get_event_loop() dl = self.delay_map(p.pub_key, self.peer.pub_key) print(dl) - print("will send in ",dl[0]/1000 + 100*len(data)/(1024**3*dl[1])) - await asyncio.sleep(dl[0]/1000 + 100*len(data)/(1024**3*dl[1])) + 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])) if self.started: return await self._lower_send_to(node_id,data) @bindto("send_stream") diff --git a/deccom/protocols/streamprotocol.py b/deccom/protocols/streamprotocol.py index 3d37930..943955b 100644 --- a/deccom/protocols/streamprotocol.py +++ b/deccom/protocols/streamprotocol.py @@ -295,7 +295,6 @@ async def send_stream(self, node_id, data, lvl = 0): with open(f"log{self.peer.pub_key}.txt", "a") as log: log.write(datetime.now().strftime("%d/%m/%Y, %H:%M:%S")) log.write(f" cannot send to {self.get_peer(node_id).pub_key} {len(data)}\n") - self.remove_from_dict(node_id) await asyncio.sleep(3) p: Peer = self.get_peer(node_id) if p == None: