Integrate security selectin into libp2p system

This commit is contained in:
Stuckinaboot
2019-04-30 03:09:05 -04:00
parent 999e64854c
commit f59f27d4d0
11 changed files with 145 additions and 74 deletions

View File

@ -1,3 +1,4 @@
import asyncio
from .raw_connection_interface import IRawConnection
@ -12,6 +13,19 @@ class RawConnection(IRawConnection):
self._next_id = 0 if initiator else 1
self.initiator = initiator
async def write(self, data):
self.writer.write(data)
self.writer.write("\n".encode())
await self.writer.drain()
async def read(self):
line = await self.reader.readline()
adjusted_line = line.decode().rstrip('\n')
# TODO: figure out a way to remove \n without going back and forth with
# encoding and decoding
return adjusted_line.encode()
def close(self):
self.writer.close()