mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2025-12-31 20:36:24 +00:00
Use trio.lowlevel instead of trio.hazmat
Since trio 0.15.0, hazmat has been deprecated. trio-typing and mypy are bumped to support newer trio and each other.
This commit is contained in:
@ -64,7 +64,7 @@ class FloodSub(IPubsubRouter):
|
||||
:param rpc: rpc message
|
||||
"""
|
||||
# Checkpoint
|
||||
await trio.hazmat.checkpoint()
|
||||
await trio.lowlevel.checkpoint()
|
||||
|
||||
async def publish(self, msg_forwarder: ID, pubsub_msg: rpc_pb2.Message) -> None:
|
||||
"""
|
||||
@ -112,7 +112,7 @@ class FloodSub(IPubsubRouter):
|
||||
:param topic: topic to join
|
||||
"""
|
||||
# Checkpoint
|
||||
await trio.hazmat.checkpoint()
|
||||
await trio.lowlevel.checkpoint()
|
||||
|
||||
async def leave(self, topic: str) -> None:
|
||||
"""
|
||||
@ -122,7 +122,7 @@ class FloodSub(IPubsubRouter):
|
||||
:param topic: topic to leave
|
||||
"""
|
||||
# Checkpoint
|
||||
await trio.hazmat.checkpoint()
|
||||
await trio.lowlevel.checkpoint()
|
||||
|
||||
def _get_peers_to_send(
|
||||
self, topic_ids: Iterable[str], msg_forwarder: ID, origin: ID
|
||||
|
||||
@ -32,10 +32,10 @@ class PubsubNotifee(INotifee):
|
||||
self.dead_peers_queue = dead_peers_queue
|
||||
|
||||
async def opened_stream(self, network: INetwork, stream: INetStream) -> None:
|
||||
await trio.hazmat.checkpoint()
|
||||
await trio.lowlevel.checkpoint()
|
||||
|
||||
async def closed_stream(self, network: INetwork, stream: INetStream) -> None:
|
||||
await trio.hazmat.checkpoint()
|
||||
await trio.lowlevel.checkpoint()
|
||||
|
||||
async def connected(self, network: INetwork, conn: INetConn) -> None:
|
||||
"""
|
||||
@ -67,7 +67,7 @@ class PubsubNotifee(INotifee):
|
||||
pass
|
||||
|
||||
async def listen(self, network: INetwork, multiaddr: Multiaddr) -> None:
|
||||
await trio.hazmat.checkpoint()
|
||||
await trio.lowlevel.checkpoint()
|
||||
|
||||
async def listen_close(self, network: INetwork, multiaddr: Multiaddr) -> None:
|
||||
await trio.hazmat.checkpoint()
|
||||
await trio.lowlevel.checkpoint()
|
||||
|
||||
@ -10,7 +10,7 @@ from .typing import UnsubscribeFn
|
||||
|
||||
class BaseSubscriptionAPI(ISubscriptionAPI):
|
||||
async def __aenter__(self) -> "BaseSubscriptionAPI":
|
||||
await trio.hazmat.checkpoint()
|
||||
await trio.lowlevel.checkpoint()
|
||||
return self
|
||||
|
||||
async def __aexit__(
|
||||
|
||||
@ -177,8 +177,6 @@ class PatternXX(BasePattern):
|
||||
def _get_pubkey_from_noise_keypair(key_pair: NoiseKeyPair) -> PublicKey:
|
||||
# Use `Ed25519PublicKey` since 25519 is used in our pattern.
|
||||
raw_bytes = key_pair.public.public_bytes(
|
||||
# ignore "'Type[...]' has no attribute 'Raw'"
|
||||
serialization.Encoding.Raw, # type: ignore
|
||||
serialization.PublicFormat.Raw, # type: ignore
|
||||
serialization.Encoding.Raw, serialization.PublicFormat.Raw
|
||||
)
|
||||
return Ed25519PublicKey.from_bytes(raw_bytes)
|
||||
|
||||
@ -297,7 +297,7 @@ class DummyRouter(IPeerRouting):
|
||||
self._routing_table[peer_id] = PeerInfo(peer_id, addrs)
|
||||
|
||||
async def find_peer(self, peer_id: ID) -> PeerInfo:
|
||||
await trio.hazmat.checkpoint()
|
||||
await trio.lowlevel.checkpoint()
|
||||
return self._routing_table.get(peer_id, None)
|
||||
|
||||
|
||||
|
||||
@ -217,7 +217,7 @@ async def perform_test_from_obj(obj, pubsub_factory) -> None:
|
||||
# Avoid repeated works
|
||||
if topic in queues_map[node_id]:
|
||||
# Checkpoint
|
||||
await trio.hazmat.checkpoint()
|
||||
await trio.lowlevel.checkpoint()
|
||||
return
|
||||
sub = await pubsub_map[node_id].subscribe(topic)
|
||||
queues_map[node_id][topic] = sub
|
||||
|
||||
@ -102,5 +102,5 @@ class TCP(ITransport):
|
||||
|
||||
|
||||
def _multiaddr_from_socket(socket: trio.socket.SocketType) -> Multiaddr:
|
||||
ip, port = socket.getsockname() # type: ignore
|
||||
ip, port = socket.getsockname()
|
||||
return Multiaddr(f"/ip4/{ip}/tcp/{port}")
|
||||
|
||||
Reference in New Issue
Block a user