implemented stream io interactions
This commit is contained in:
parent
48dfd9a77a
commit
007d9915e2
|
@ -9,6 +9,8 @@ class Stream(IStream):
|
||||||
|
|
||||||
peer_store = context.peer_store
|
peer_store = context.peer_store
|
||||||
peer_addr = peer_store.get(peer_id)
|
peer_addr = peer_store.get(peer_id)
|
||||||
|
ip = peer_addr.get_protocol("ip4")
|
||||||
|
port = peer_addr.get_protocol("tcp")
|
||||||
|
|
||||||
# look up peer_id -> multiaddr in peer store
|
# look up peer_id -> multiaddr in peer store
|
||||||
# parse multiaddr and set_protocol based on it
|
# parse multiaddr and set_protocol based on it
|
||||||
|
@ -37,18 +39,23 @@ class Stream(IStream):
|
||||||
read from stream
|
read from stream
|
||||||
:return: bytes of input
|
:return: bytes of input
|
||||||
"""
|
"""
|
||||||
pass
|
return self.reader.read(-1)
|
||||||
|
|
||||||
def write(self, _bytes):
|
def write(self, _bytes):
|
||||||
"""
|
"""
|
||||||
write to stream
|
write to stream
|
||||||
:return: number of bytes written
|
:return: number of bytes written
|
||||||
"""
|
"""
|
||||||
pass
|
return self.write_to_stream(_bytes)
|
||||||
|
|
||||||
|
async def write_to_stream(self, _bytes):
|
||||||
|
to_return = self.writer.write(_bytes)
|
||||||
|
await self.writer.drain()
|
||||||
|
return to_return
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
"""
|
"""
|
||||||
close stream
|
close stream
|
||||||
:return: true if successful
|
:return: true if successful
|
||||||
"""
|
"""
|
||||||
pass
|
self.writer.close()
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
asyncio
|
asyncio
|
||||||
|
multiaddr
|
Loading…
Reference in New Issue
Block a user