1
0

introduce gossip query handling and forwarding

This commit is contained in:
f321x
2025-01-23 14:22:17 +01:00
committed by f321x
parent fad6559150
commit d348da811a
6 changed files with 509 additions and 38 deletions

View File

@@ -199,6 +199,9 @@ class LNTransportBase:
privkey: bytes
peer_addr: Optional[LNPeerAddr] = None
def __init__(self):
self.drain_write_lock = asyncio.Lock()
def name(self) -> str:
pubkey = self.remote_pubkey()
pubkey_hex = pubkey.hex() if pubkey else pubkey
@@ -218,6 +221,12 @@ class LNTransportBase:
assert len(c) == len(msg) + 16
self.writer.write(lc+c)
async def send_bytes_and_drain(self, msg: bytes) -> None:
"""Should be used when possible (in async scope), to avoid memory exhaustion."""
async with self.drain_write_lock:
self.send_bytes(msg)
await self.writer.drain()
async def read_messages(self):
buffer = bytearray()
while True: