mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2025-12-31 20:36:24 +00:00
Convert from base58/pubkey/privkey to class method
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
from typing import Iterable, List, Sequence
|
||||
|
||||
from libp2p.peer.id import ID, id_b58_decode
|
||||
from libp2p.peer.id import ID
|
||||
|
||||
from .pb import rpc_pb2
|
||||
from .pubsub import Pubsub
|
||||
@ -106,7 +106,7 @@ class FloodSub(IPubsubRouter):
|
||||
if topic not in self.pubsub.peer_topics:
|
||||
continue
|
||||
for peer_id_str in self.pubsub.peer_topics[topic]:
|
||||
peer_id = id_b58_decode(peer_id_str)
|
||||
peer_id = ID.from_base58(peer_id_str)
|
||||
if peer_id in (msg_forwarder, origin):
|
||||
continue
|
||||
# FIXME: Should change `self.pubsub.peers` to Dict[PeerID, ...]
|
||||
|
||||
@ -1,9 +1,16 @@
|
||||
from ast import literal_eval
|
||||
import asyncio
|
||||
import random
|
||||
from typing import Any, Dict, Iterable, List, Set, Sequence
|
||||
from typing import (
|
||||
Any,
|
||||
Dict,
|
||||
Iterable,
|
||||
List,
|
||||
Set,
|
||||
Sequence,
|
||||
)
|
||||
|
||||
from libp2p.peer.id import ID, id_b58_decode
|
||||
from libp2p.peer.id import ID
|
||||
|
||||
from .mcache import MessageCache
|
||||
from .pb import rpc_pb2
|
||||
@ -201,7 +208,7 @@ class GossipSub(IPubsubRouter):
|
||||
# FIXME: `gossipsub.peers_floodsub` can be changed to `gossipsub.peers` in go.
|
||||
# This will improve the efficiency when searching for a peer's protocol id.
|
||||
if peer_id_str in self.peers_floodsub:
|
||||
peer_id = id_b58_decode(peer_id_str)
|
||||
peer_id = ID.from_base58(peer_id_str)
|
||||
send_to.add(peer_id)
|
||||
|
||||
# gossipsub peers
|
||||
@ -223,7 +230,7 @@ class GossipSub(IPubsubRouter):
|
||||
)
|
||||
in_topic_gossipsub_peers = self.fanout[topic]
|
||||
for peer_id_str in in_topic_gossipsub_peers:
|
||||
send_to.add(id_b58_decode(peer_id_str))
|
||||
send_to.add(ID.from_base58(peer_id_str))
|
||||
# Excludes `msg_forwarder` and `origin`
|
||||
yield from send_to.difference([msg_forwarder, origin])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user