Show / Hide Table of Contents

Class MultiAddress

A set of steps describing how to build up a connection.

Inheritance
Object
MultiAddress
Implements
IEquatable<MultiAddress>
Inherited Members
Object.Equals(Object, Object)
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Namespace: Ipfs
Assembly: Ipfs.Core.dll
Syntax
[JsonConverter(typeof(MultiAddress.Json))]
public class MultiAddress : IEquatable<MultiAddress>
Remarks

A multi address emphasizes explicitness, self-description, and portability. It allows applications to treat addresses as opaque tokens which avoids making assumptions about the address representation (e.g. length).

A multi address is represented as a series of protocol codes and values pairs. For example, an IPFS file at a sepcific address over ipv4 and tcp is "/ip4/10.1.10.10/tcp/29087/ipfs/QmVcSqVEsvm5RR9mBLjwpb2XjFVn5bPdPL69mL8PH45pPC".

A multi address is considered immutablle and value type equality is implemented.

Constructors

| Improve this Doc View Source

MultiAddress()

Creates a new instance of the MultiAddress class.

Declaration
public MultiAddress()
| Improve this Doc View Source

MultiAddress(Byte[])

Creates a new instance of the MultiAddress class from the specified byte array.

Declaration
public MultiAddress(byte[] buffer)
Parameters
Type Name Description
Byte[] buffer

( A byte array containing the binary representation of a MultiAddress.

Remarks

Reads the binary representation of MultiAddress from the buffer.

The binary representation is a sequence of NetworkProtocol.

| Improve this Doc View Source

MultiAddress(Stream)

Creates a new instance of the MultiAddress class from the specified Stream.

Declaration
public MultiAddress(Stream stream)
Parameters
Type Name Description
Stream stream

A Stream containing the binary representation of a MultiAddress.

Remarks

Reads the binary representation of MultiAddress from the stream.

The binary representation is a sequence of NetworkProtocol.

| Improve this Doc View Source

MultiAddress(IPAddress)

Creates a new instance of the MultiAddress class from the specified IPAddress.

Declaration
public MultiAddress(IPAddress ip)
Parameters
Type Name Description
IPAddress ip
| Improve this Doc View Source

MultiAddress(IPEndPoint)

Creates a new instance of the MultiAddress class from the specified IPEndPoint.

Declaration
public MultiAddress(IPEndPoint endpoint)
Parameters
Type Name Description
IPEndPoint endpoint
| Improve this Doc View Source

MultiAddress(String)

Creates a new instance of the MultiAddress class with the string.

Declaration
public MultiAddress(string s)
Parameters
Type Name Description
String s

The string representation of a multi address, such as "/ip4/1270.0.01/tcp/5001".

Properties

| Improve this Doc View Source

HasPeerId

Determines if the peer ID is present.

Declaration
public bool HasPeerId { get; }
Property Value
Type Description
Boolean

true if the peer ID present; otherwise, false.

Remarks

The peer ID is contained in the last protocol that is "ipfs" or "p2p". For example, /ip4/10.1.10.10/tcp/29087/ipfs/QmVcSqVEsvm5RR9mBLjwpb2XjFVn5bPdPL69mL8PH45pPC.

| Improve this Doc View Source

PeerId

Gets the peer ID of the multiaddress.

Declaration
public MultiHash PeerId { get; }
Property Value
Type Description
MultiHash

The Id as a MultiHash.

Remarks

The peer ID is contained in the last protocol that is "ipfs" or "p2p". For example, /ip4/10.1.10.10/tcp/29087/ipfs/QmVcSqVEsvm5RR9mBLjwpb2XjFVn5bPdPL69mL8PH45pPC.

Exceptions
Type Condition
Exception

When the last Protocols is not "ipfs" nor "p2p".

| Improve this Doc View Source

Protocols

The components of the MultiAddress.

Declaration
public List<NetworkProtocol> Protocols { get; }
Property Value
Type Description
List<NetworkProtocol>

Methods

| Improve this Doc View Source

Clone()

Creates a deep copy of the multi address.

Declaration
public MultiAddress Clone()
Returns
Type Description
MultiAddress

A new deep copy.

| Improve this Doc View Source

Equals(MultiAddress)

Declaration
public bool Equals(MultiAddress that)
Parameters
Type Name Description
MultiAddress that
Returns
Type Description
Boolean
| Improve this Doc View Source

Equals(Object)

Declaration
public override bool Equals(object obj)
Parameters
Type Name Description
Object obj
Returns
Type Description
Boolean
Overrides
Object.Equals(Object)
| Improve this Doc View Source

GetHashCode()

Declaration
public override int GetHashCode()
Returns
Type Description
Int32
Overrides
Object.GetHashCode()
| Improve this Doc View Source

ToArray()

Returns the IPFS binary representation as a byte array.

Declaration
public byte[] ToArray()
Returns
Type Description
Byte[]

A byte array.

Remarks

The binary representation is a sequence of NetworkProtocol.

| Improve this Doc View Source

ToString()

A sequence of NetworkProtocol that is readable to a human.

Declaration
public override string ToString()
Returns
Type Description
String
Overrides
Object.ToString()
| Improve this Doc View Source

TryCreate(Byte[])

Try to create a MultiAddress from the specified the binary encoding.

Declaration
public static MultiAddress TryCreate(byte[] bytes)
Parameters
Type Name Description
Byte[] bytes

The binary encoding of a multiaddress.

Returns
Type Description
MultiAddress

null if the bytes cannot be parsed; otherwise a MultiAddress.

| Improve this Doc View Source

TryCreate(String)

Try to create a MultiAddress from the specified string.

Declaration
public static MultiAddress TryCreate(string s)
Parameters
Type Name Description
String s

The string representation of a multi address, such as "/ip4/1270.0.01/tcp/5001".

Returns
Type Description
MultiAddress

null if the string cannot be parsed; otherwise a MultiAddress.

| Improve this Doc View Source

WithoutPeerId()

Gets a multiaddress without the peer ID.

Declaration
public MultiAddress WithoutPeerId()
Returns
Type Description
MultiAddress

Either the this multiaddress when it does not contain a peer ID; or a new MultiAddress without the peer ID.

| Improve this Doc View Source

WithPeerId(MultiHash)

Gets a multiaddress that ends with the peer ID.

Declaration
public MultiAddress WithPeerId(MultiHash peerId)
Parameters
Type Name Description
MultiHash peerId

The peer ID to end the multiaddress with.

Returns
Type Description
MultiAddress

Either the this multiadddress when it contains the peerId or a new MultiAddress ending the peerId.

Exceptions
Type Condition
Exception

When the mulltiaddress has the wrong peer ID.

| Improve this Doc View Source

Write(CodedOutputStream)

Writes the binary representation to the specified Google.Protobuf.CodedOutputStream.

Declaration
public void Write(CodedOutputStream stream)
Parameters
Type Name Description
Google.Protobuf.CodedOutputStream stream

The Google.Protobuf.CodedOutputStream to write to.

Remarks

The binary representation is a sequence of NetworkProtocol.

| Improve this Doc View Source

Write(Stream)

Writes the binary representation to the specified Stream.

Declaration
public void Write(Stream stream)
Parameters
Type Name Description
Stream stream

The Stream to write to.

Remarks

The binary representation is a sequence of NetworkProtocol.

| Improve this Doc View Source

Write(TextWriter)

Writes the string representation to the specified TextWriter.

Declaration
public void Write(TextWriter stream)
Parameters
Type Name Description
TextWriter stream

The TextWriter to write to.

Remarks

The string representation is a sequence of NetworkProtocol.

Operators

| Improve this Doc View Source

Equality(MultiAddress, MultiAddress)

Value equality.

Declaration
public static bool operator ==(MultiAddress a, MultiAddress b)
Parameters
Type Name Description
MultiAddress a
MultiAddress b
Returns
Type Description
Boolean
| Improve this Doc View Source

Implicit(String to MultiAddress)

Implicit casting of a String to a MultiAddress.

Declaration
public static implicit operator MultiAddress(string s)
Parameters
Type Name Description
String s

The string representation of a MultiAddress.

Returns
Type Description
MultiAddress

A new MultiAddress.

| Improve this Doc View Source

Inequality(MultiAddress, MultiAddress)

Value inequality.

Declaration
public static bool operator !=(MultiAddress a, MultiAddress b)
Parameters
Type Name Description
MultiAddress a
MultiAddress b
Returns
Type Description
Boolean

Implements

System.IEquatable<T>

See Also

https://github.com/multiformats/multiaddr
  • Improve this Doc
  • View Source
Back to top Generated by DocFX