mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2026-02-11 07:30:55 +00:00
run lint and fix errors, except mypy
This commit is contained in:
@ -1,10 +1,19 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from abc import (
|
||||
ABC,
|
||||
abstractmethod,
|
||||
)
|
||||
|
||||
import trio
|
||||
|
||||
from libp2p.io.abc import ReadWriteCloser
|
||||
from libp2p.peer.id import ID
|
||||
from libp2p.security.secure_conn_interface import ISecureConn
|
||||
from libp2p.io.abc import (
|
||||
ReadWriteCloser,
|
||||
)
|
||||
from libp2p.peer.id import (
|
||||
ID,
|
||||
)
|
||||
from libp2p.security.secure_conn_interface import (
|
||||
ISecureConn,
|
||||
)
|
||||
|
||||
|
||||
class IMuxedConn(ABC):
|
||||
@ -18,7 +27,7 @@ class IMuxedConn(ABC):
|
||||
@abstractmethod
|
||||
def __init__(self, conn: ISecureConn, peer_id: ID) -> None:
|
||||
"""
|
||||
create a new muxed connection.
|
||||
Create a new muxed connection.
|
||||
|
||||
:param conn: an instance of secured connection
|
||||
for new muxed streams
|
||||
@ -28,21 +37,21 @@ class IMuxedConn(ABC):
|
||||
@property
|
||||
@abstractmethod
|
||||
def is_initiator(self) -> bool:
|
||||
"""if this connection is the initiator."""
|
||||
"""If this connection is the initiator."""
|
||||
|
||||
@abstractmethod
|
||||
async def start(self) -> None:
|
||||
"""start the multiplexer."""
|
||||
"""Start the multiplexer."""
|
||||
|
||||
@abstractmethod
|
||||
async def close(self) -> None:
|
||||
"""close connection."""
|
||||
"""Close connection."""
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def is_closed(self) -> bool:
|
||||
"""
|
||||
check connection is fully closed.
|
||||
Check connection is fully closed.
|
||||
|
||||
:return: true if successful
|
||||
"""
|
||||
@ -50,28 +59,27 @@ class IMuxedConn(ABC):
|
||||
@abstractmethod
|
||||
async def open_stream(self) -> "IMuxedStream":
|
||||
"""
|
||||
creates a new muxed_stream.
|
||||
Create a new muxed_stream.
|
||||
|
||||
:return: a new ``IMuxedStream`` stream
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
async def accept_stream(self) -> "IMuxedStream":
|
||||
"""accepts a muxed stream opened by the other end."""
|
||||
"""Accept a muxed stream opened by the other end."""
|
||||
|
||||
|
||||
class IMuxedStream(ReadWriteCloser):
|
||||
|
||||
muxed_conn: IMuxedConn
|
||||
|
||||
@abstractmethod
|
||||
async def reset(self) -> None:
|
||||
"""closes both ends of the stream tells this remote side to hang up."""
|
||||
"""Close both ends of the stream tells this remote side to hang up."""
|
||||
|
||||
@abstractmethod
|
||||
def set_deadline(self, ttl: int) -> bool:
|
||||
"""
|
||||
set deadline for muxed stream.
|
||||
Set deadline for muxed stream.
|
||||
|
||||
:return: a new stream
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user