run black
This commit is contained in:
parent
9e0a806218
commit
7a04ebb51f
|
@ -90,9 +90,7 @@ class Mplex(IMuxedConn):
|
|||
# Stream not created yet
|
||||
return None
|
||||
|
||||
async def open_stream(
|
||||
self, protocol_id: str, multi_addr: Multiaddr
|
||||
) -> IMuxedStream:
|
||||
async def open_stream(self, protocol_id: str, multi_addr: Multiaddr) -> IMuxedStream:
|
||||
"""
|
||||
creates a new muxed_stream
|
||||
:param protocol_id: protocol_id of stream
|
||||
|
|
|
@ -47,11 +47,7 @@ class MplexStream(IMuxedStream):
|
|||
write to stream
|
||||
:return: number of bytes written
|
||||
"""
|
||||
flag = (
|
||||
HeaderTags.MessageInitiator
|
||||
if self.initiator
|
||||
else HeaderTags.MessageReceiver
|
||||
)
|
||||
flag = HeaderTags.MessageInitiator if self.initiator else HeaderTags.MessageReceiver
|
||||
return await self.mplex_conn.send_message(flag, data, self.stream_id)
|
||||
|
||||
async def close(self) -> bool:
|
||||
|
@ -93,11 +89,7 @@ class MplexStream(IMuxedStream):
|
|||
return True
|
||||
|
||||
if not self.remote_closed:
|
||||
flag = (
|
||||
HeaderTags.ResetInitiator
|
||||
if self.initiator
|
||||
else HeaderTags.ResetInitiator
|
||||
)
|
||||
flag = HeaderTags.ResetInitiator if self.initiator else HeaderTags.ResetInitiator
|
||||
await self.mplex_conn.send_message(flag, None, self.stream_id)
|
||||
|
||||
self.local_closed = True
|
||||
|
|
|
@ -32,9 +32,7 @@ def decode_uvarint(buff: bytes, index: int) -> Tuple[int, int]:
|
|||
return result, index + 1
|
||||
|
||||
|
||||
async def decode_uvarint_from_stream(
|
||||
reader: asyncio.StreamReader, timeout: float
|
||||
) -> int:
|
||||
async def decode_uvarint_from_stream(reader: asyncio.StreamReader, timeout: float) -> int:
|
||||
shift = 0
|
||||
result = 0
|
||||
while True:
|
||||
|
|
|
@ -30,9 +30,7 @@ class TCPListener(IListener):
|
|||
:return: return True if successful
|
||||
"""
|
||||
self.server = await asyncio.start_server(
|
||||
self.handler,
|
||||
maddr.value_for_protocol("ip4"),
|
||||
maddr.value_for_protocol("tcp"),
|
||||
self.handler, maddr.value_for_protocol("ip4"), maddr.value_for_protocol("tcp")
|
||||
)
|
||||
socket = self.server.sockets[0]
|
||||
self.multiaddrs.append(_multiaddr_from_socket(socket))
|
||||
|
|
|
@ -3,4 +3,3 @@ from typing import NewType, Callable
|
|||
|
||||
|
||||
THandler = Callable[[StreamReader, StreamWriter], None]
|
||||
|
||||
|
|
|
@ -16,9 +16,7 @@ class TransportUpgrader:
|
|||
security_multistream: SecurityMultistream
|
||||
muxer: Sequence[str]
|
||||
|
||||
def __init__(
|
||||
self, secOpt: Dict[TProtocol, ISecureTransport], muxerOpt: Sequence[str]
|
||||
) -> None:
|
||||
def __init__(self, secOpt: Dict[TProtocol, ISecureTransport], muxerOpt: Sequence[str]) -> None:
|
||||
# Store security option
|
||||
self.security_multistream = SecurityMultistream()
|
||||
for key in secOpt:
|
||||
|
@ -46,9 +44,7 @@ class TransportUpgrader:
|
|||
|
||||
@staticmethod
|
||||
def upgrade_connection(
|
||||
conn: IRawConnection,
|
||||
generic_protocol_handler: GenericProtocolHandlerFn,
|
||||
peer_id: ID,
|
||||
conn: IRawConnection, generic_protocol_handler: GenericProtocolHandlerFn, peer_id: ID
|
||||
) -> Mplex:
|
||||
"""
|
||||
Upgrade raw connection to muxed connection
|
||||
|
|
|
@ -8,7 +8,9 @@ from libp2p.peer.peerdata import PeerData
|
|||
from libp2p.peer.peerinfo import InvalidAddrError, PeerInfo, info_from_p2p_addr
|
||||
|
||||
ALPHABETS = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
|
||||
VALID_MULTI_ADDR_STR = "/ip4/127.0.0.1/tcp/8000/p2p/3YgLAeMKSAPcGqZkAt8mREqhQXmJT8SN8VCMN4T6ih4GNX9wvK8mWJnWZ1qA2mLdCQ" # noqa: E501
|
||||
VALID_MULTI_ADDR_STR = (
|
||||
"/ip4/127.0.0.1/tcp/8000/p2p/3YgLAeMKSAPcGqZkAt8mREqhQXmJT8SN8VCMN4T6ih4GNX9wvK8mWJnWZ1qA2mLdCQ"
|
||||
) # noqa: E501
|
||||
|
||||
|
||||
def test_init_():
|
||||
|
|
Loading…
Reference in New Issue
Block a user