From e37b8bcf1952f67fcd25e74fbe8403934a706065 Mon Sep 17 00:00:00 2001 From: mhchia Date: Mon, 12 Aug 2019 14:40:31 +0800 Subject: [PATCH] mypy: Add `read_buffer_nonblocking` in Mplex --- libp2p/crypto/secp256k1.py | 1 - libp2p/stream_muxer/abc.py | 8 +++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/libp2p/crypto/secp256k1.py b/libp2p/crypto/secp256k1.py index 79ffc9d1..0e5b9a57 100644 --- a/libp2p/crypto/secp256k1.py +++ b/libp2p/crypto/secp256k1.py @@ -1,5 +1,4 @@ import coincurve - from libp2p.crypto.keys import KeyPair, KeyType, PrivateKey, PublicKey diff --git a/libp2p/stream_muxer/abc.py b/libp2p/stream_muxer/abc.py index 5c111070..7084d7a3 100644 --- a/libp2p/stream_muxer/abc.py +++ b/libp2p/stream_muxer/abc.py @@ -1,5 +1,5 @@ from abc import ABC, abstractmethod -from typing import TYPE_CHECKING +from typing import TYPE_CHECKING, Optional from multiaddr import Multiaddr @@ -56,6 +56,12 @@ class IMuxedConn(ABC): :return: message read """ + @abstractmethod + async def read_buffer_nonblocking(self, stream_id: int) -> Optional[bytes]: + """ + Read a message from `stream_id`'s buffer, non-blockingly. + """ + @abstractmethod async def open_stream( self, protocol_id: str, multi_addr: Multiaddr