Fix gossip server not closing connections
This commit is contained in:
parent
3643e4f8d7
commit
3852b15c89
@ -120,14 +120,13 @@ def gossip_server():
|
|||||||
if blockdb.has_block(block_id):
|
if blockdb.has_block(block_id):
|
||||||
writer.write(int(0).to_bytes(1, 'big'))
|
writer.write(int(0).to_bytes(1, 'big'))
|
||||||
else:
|
else:
|
||||||
|
|
||||||
writer.write(int(1).to_bytes(1, 'big'))
|
writer.write(int(1).to_bytes(1, 'big'))
|
||||||
await writer.drain()
|
await writer.drain()
|
||||||
block_size = int(await asyncio.wait_for(reader.readexactly(constants.BLOCK_SIZE_LEN), 30))
|
block_size = int(await asyncio.wait_for(reader.readexactly(constants.BLOCK_SIZE_LEN), 30))
|
||||||
block_data = await reader.readexactly(block_size)
|
block_data = await reader.readexactly(block_size)
|
||||||
|
|
||||||
Thread(
|
Thread(
|
||||||
target=add_block_to_db,
|
target=add_block_to_db,
|
||||||
args=[
|
args=[
|
||||||
Block(block_id, block_data, auto_verify=True)]
|
Block(block_id, block_data, auto_verify=True)]
|
||||||
).start()
|
).start()
|
||||||
@ -137,6 +136,7 @@ def gossip_server():
|
|||||||
await writer.drain()
|
await writer.drain()
|
||||||
except BrokenPipeError:
|
except BrokenPipeError:
|
||||||
pass
|
pass
|
||||||
|
writer.close()
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user