mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2025-12-31 20:36:24 +00:00
WIP CI Build Errors (#76)
* ignore TODO and kademlia * remove unnecessary pass * fixed swarm warnings * fixed peerdata_interface warnings * fixed peer warnings * fixed rest of linting errors * trying to fix last error * fixed dup errors
This commit is contained in:
@ -2,6 +2,7 @@ from .raw_connection_interface import IRawConnection
|
||||
|
||||
|
||||
class RawConnection(IRawConnection):
|
||||
# pylint: disable=too-few-public-methods
|
||||
|
||||
def __init__(self, ip, port, reader, writer):
|
||||
self.conn_ip = ip
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
from abc import ABC
|
||||
|
||||
# pylint: disable=too-few-public-methods
|
||||
|
||||
class IRawConnection(ABC):
|
||||
"""
|
||||
|
||||
@ -120,4 +120,3 @@ class MultiAddr:
|
||||
|
||||
class MultiAddrValueError(ValueError):
|
||||
"""Raised when the input string to the MultiAddr constructor was invalid."""
|
||||
pass
|
||||
|
||||
@ -8,7 +8,6 @@ class INetwork(ABC):
|
||||
"""
|
||||
:return: the peer id
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def set_stream_handler(self, protocol_id, stream_handler):
|
||||
@ -17,7 +16,6 @@ class INetwork(ABC):
|
||||
:param stream_handler: a stream handler instance
|
||||
:return: true if successful
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def new_stream(self, peer_id, protocol_id):
|
||||
@ -26,7 +24,6 @@ class INetwork(ABC):
|
||||
:param protocol_id: protocol id
|
||||
:return: stream instance
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def listen(self, *args):
|
||||
@ -34,4 +31,3 @@ class INetwork(ABC):
|
||||
:param *args: one or many multiaddrs to start listening on
|
||||
:return: True if at least one success
|
||||
"""
|
||||
pass
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
|
||||
class INetStream(ABC):
|
||||
|
||||
@abstractmethod
|
||||
@ -8,7 +7,6 @@ class INetStream(ABC):
|
||||
"""
|
||||
:return: protocol id that stream runs on
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def set_protocol(self, protocol_id):
|
||||
@ -16,28 +14,24 @@ class INetStream(ABC):
|
||||
:param protocol_id: protocol id that stream runs on
|
||||
:return: true if successful
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def read(self):
|
||||
"""
|
||||
read from stream
|
||||
reads from the underlying muxed_stream
|
||||
:return: bytes of input
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def write(self, _bytes):
|
||||
"""
|
||||
write to stream
|
||||
write to the underlying muxed_stream
|
||||
:return: number of bytes written
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def close(self):
|
||||
"""
|
||||
close stream
|
||||
close the underlying muxed stream
|
||||
:return: true if successful
|
||||
"""
|
||||
pass
|
||||
|
||||
@ -1,16 +1,15 @@
|
||||
import uuid
|
||||
from peer.id import ID
|
||||
from .network_interface import INetwork
|
||||
from .stream.net_stream import NetStream
|
||||
from .multiaddr import MultiAddr
|
||||
from .connection.raw_connection import RawConnection
|
||||
|
||||
from peer.id import ID
|
||||
|
||||
class Swarm(INetwork):
|
||||
# pylint: disable=too-many-instance-attributes, cell-var-from-loop
|
||||
|
||||
def __init__(self, my_peer_id, peerstore, upgrader):
|
||||
self._my_peer_id = my_peer_id
|
||||
self.id = ID(my_peer_id)
|
||||
self.self_id = ID(my_peer_id)
|
||||
self.peerstore = peerstore
|
||||
self.upgrader = upgrader
|
||||
self.connections = dict()
|
||||
@ -19,7 +18,7 @@ class Swarm(INetwork):
|
||||
self.transport = None
|
||||
|
||||
def get_peer_id(self):
|
||||
return self.id
|
||||
return self.self_id
|
||||
|
||||
def set_stream_handler(self, protocol_id, stream_handler):
|
||||
"""
|
||||
@ -94,7 +93,7 @@ class Swarm(INetwork):
|
||||
multiaddr_dict['port'], reader, writer)
|
||||
muxed_conn = self.upgrader.upgrade_connection(raw_conn, False)
|
||||
|
||||
muxed_stream, stream_id, protocol_id = await muxed_conn.accept_stream()
|
||||
muxed_stream, _, protocol_id = await muxed_conn.accept_stream()
|
||||
net_stream = NetStream(muxed_stream)
|
||||
net_stream.set_protocol(protocol_id)
|
||||
|
||||
@ -106,7 +105,7 @@ class Swarm(INetwork):
|
||||
try:
|
||||
# Success
|
||||
listener = self.transport.create_listener(conn_handler)
|
||||
self.listeners[multiaddr_str] = listener
|
||||
self.listeners[multiaddr_str] = listener
|
||||
await listener.listen(multiaddr)
|
||||
return True
|
||||
except IOError:
|
||||
|
||||
Reference in New Issue
Block a user