Skip to content

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 address
  • port: port number of the address
  • public_key: hex encoded public key. Must conform to Bitcoin EC encoding standard for Secp256k1
  • multihash_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.