Fix missing asterisk
This commit is contained in:
parent
3a4b592a5a
commit
ee290b2ac2
|
@ -82,38 +82,6 @@ class ID:
|
|||
return cls.from_pubkey(key.publickey())
|
||||
|
||||
|
||||
def id_b58_encode(peer_id: ID) -> str:
|
||||
"""
|
||||
return a b58-encoded string
|
||||
"""
|
||||
# pylint: disable=protected-access
|
||||
return base58.b58encode(peer_id.to_bytes()).decode()
|
||||
|
||||
|
||||
def id_b58_decode(b58_encoded_peer_id_str: str) -> ID:
|
||||
"""
|
||||
return a base58-decoded peer ID
|
||||
"""
|
||||
return ID(base58.b58decode(b58_encoded_peer_id_str))
|
||||
|
||||
|
||||
def id_from_public_key(key: RsaKey) -> ID:
|
||||
# export into binary format
|
||||
key_bin = key.exportKey("DER")
|
||||
|
||||
algo: int = multihash.Func.sha2_256
|
||||
# TODO: seems identity is not yet supported in pymultihash
|
||||
# if len(b) <= MAX_INLINE_KEY_LENGTH:
|
||||
# algo multihash.func.identity
|
||||
|
||||
mh_digest: multihash.Multihash = multihash.digest(key_bin, algo)
|
||||
return ID(mh_digest.encode())
|
||||
|
||||
|
||||
def id_from_private_key(key: RsaKey) -> ID:
|
||||
return id_from_public_key(key.publickey())
|
||||
|
||||
|
||||
def digest(data: Union[str, bytes]) -> bytes:
|
||||
if isinstance(data, str):
|
||||
data = data.encode("utf8")
|
||||
|
|
|
@ -3,7 +3,7 @@ import asyncio
|
|||
import multiaddr
|
||||
|
||||
from libp2p.network.connection.raw_connection import RawConnection
|
||||
from libp2p.peer.id import id_b58_encode
|
||||
from libp2p.peer.id import ID
|
||||
|
||||
from ..listener_interface import IListener
|
||||
from ..transport_interface import ITransport
|
||||
|
@ -74,7 +74,7 @@ class TCP(ITransport):
|
|||
reader, writer = await asyncio.open_connection(host, port)
|
||||
|
||||
# First: send our peer ID so receiver knows it
|
||||
writer.write(id_b58_encode(self_id).encode())
|
||||
writer.write(self_id.to_base58().encode())
|
||||
await writer.drain()
|
||||
|
||||
# Await ack for peer id
|
||||
|
|
Loading…
Reference in New Issue
Block a user