New type: MultiaddrWithId

I propose to add a new type: MultiaddrWithId which is essentially a multiaddr + peer id.
Note: peer id is a Qm + base58(sha256(public key)) (https://github.com/ipfs/faq/issues/22)

$multiaddr/p2p/$base58_peerid
"/ip4/192.168.0.1/tcp/1234/p2p/BYptxaTgpcBrqZx9tghNCWFfUuYBcGfLydEvDjXqBV7k"

For example.
Listen will accept Multiaddress, but Dial will accept MultiaddrWithId. Because just looking at the source code it is not clear where MultiaddrWithId should be used.

P.S. Looking for a better name for this primitive.

^^ this is actually a valid multiaddr. Multiaddrs not only describe network location and protocol info, but also identity (/p2p), routing (/p2p-circuit) and in the future, security (e.g. /secio, /noise, /tls).

BTW: Have a look at the PeerInfo type in go-libp2p; I think it’s close to what you describe.

1 Like

the peerstore module also has utilities to convert between PeerInfo and these multiaddreses (and back).