aea.helpers.multiaddr.base
This module contains multiaddress class.
MultiAddr Objects
class MultiAddr()
Protocol Labs' Multiaddress representation of a network address.
__
init__
def __init__(host: str,
port: int,
public_key: Optional[str] = None,
multihash_id: Optional[str] = None) -> None
Initialize a multiaddress.
Arguments:
host
: ip host of the addressport
: port number of the addresspublic_key
: hex encoded public key. Must conform to Bitcoin EC encoding standard for Secp256k1multihash_id
: a multihash of the public key
compute_
peerid
@staticmethod
def compute_peerid(public_key: str) -> str
Compute the peer id from a public key.
In particular, compute the base58 representation of libp2p PeerID from Bitcoin EC encoded Secp256k1 public key.
Arguments:
public_key
: the public key.
Returns:
the peer id.
from_
string
@classmethod
def from_string(cls, maddr: str) -> "MultiAddr"
Construct a MultiAddr object from its string format
Arguments:
maddr
: multiaddress string
Returns:
multiaddress object
public_
key
@property
def public_key() -> str
Get the public key.
peer_
id
@property
def peer_id() -> str
Get the peer id.
host
@property
def host() -> str
Get the peer host.
port
@property
def port() -> int
Get the peer port.
format
def format() -> str
Canonical representation of a multiaddress.
__
str__
def __str__() -> str
Default string representation of a multiaddress.