@@ -244,7 +244,7 @@ async def listen_for_data(self, reader: asyncio.StreamReader, node_id = None, ad
244244 except (ConnectionResetError , BrokenPipeError ,IncompleteReadError ) as e :
245245 with open (f"log{ self .peer .pub_key } .txt" , "a" ) as log :
246246 log .write (datetime .now ().strftime ("%d/%m/%Y, %H:%M:%S" ))
247- log .write (f" closed because reset from { node_id } \n " )
247+ log .write (f" closed because reset from { self . get_peer ( node_id ). pub_key } \n " )
248248 # log.write(e)
249249 log .write ("\n " )
250250 async with self .locks [node_id ]:
@@ -264,15 +264,15 @@ async def listen_for_data(self, reader: asyncio.StreamReader, node_id = None, ad
264264 return
265265 if node_id != None and self .connections .get (node_id ) != None :
266266 self .connections [node_id ].fut = None
267- print ( "closing because received empty bytes" , addr , node_id )
267+
268268 self .remove_from_dict (node_id )
269269 self .closed_stream (node_id , addr )
270270 return
271271 buffer = bytearray ()
272272 i = int .from_bytes (data ,byteorder = "big" )
273273 if i != 0 :
274274 with open (f"log{ self .peer .pub_key } .txt" , "a" ) as log :
275- # log.write(datetime.now().strftime("%d/%m/%Y, %H:%M:%S"))
275+
276276 log .write (f" will from { self .get_peer (node_id ).pub_key } { i } { len (data )} \n " )
277277
278278 while i > 0 :
@@ -283,6 +283,9 @@ async def listen_for_data(self, reader: asyncio.StreamReader, node_id = None, ad
283283 return
284284 if node_id != None and self .connections .get (node_id ) != None :
285285 self .connections [node_id ].fut = None
286+ with open (f"log{ self .peer .pub_key } .txt" , "a" ) as log :
287+
288+ log .write (f" closed because empty bytes from { self .get_peer (node_id ).pub_key } { len (buffer )} \n " )
286289 # print("closing because received empty bytes", addr,node_id)
287290 self .remove_from_dict (node_id )
288291 self .closed_stream (node_id , addr )
0 commit comments