Class DagNode
A node in the IPFS Merkle DAG.
Inherited Members
Namespace: Ipfs
Assembly: Ipfs.Core.dll
Syntax
[DataContract]
public class DagNode : IMerkleNode<IMerkleLink>, IDataBlock
Remarks
Constructors
| Improve this Doc View SourceDagNode(CodedInputStream)
Creates a new instance of the DagNode class from the specified Google.Protobuf.CodedInputStream.
Declaration
public DagNode(CodedInputStream stream)
Parameters
Type | Name | Description |
---|---|---|
Google.Protobuf.CodedInputStream | stream | ( A Google.Protobuf.CodedInputStream containing the binary representation of the DagNode. |
DagNode(Byte[], IEnumerable<IMerkleLink>, String)
Declaration
public DagNode(byte[] data, IEnumerable<IMerkleLink> links = null, string hashAlgorithm = "sha2-256")
Parameters
Type | Name | Description |
---|---|---|
Byte[] | data | The opaque data, can be null. |
IEnumerable<IMerkleLink> | links | The links to other nodes. |
String | hashAlgorithm | The name of the hashing algorithm to use; defaults to DefaultAlgorithmName. |
DagNode(Stream)
Declaration
public DagNode(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | A Stream containing the binary representation of the DagNode. |
Properties
| Improve this Doc View SourceDataBytes
Contents as a byte array.
Declaration
[DataMember]
public byte[] DataBytes { get; }
Property Value
Type | Description |
---|---|
Byte[] | The contents as a sequence of bytes. |
Remarks
It is never null.
DataStream
Contents as a stream of bytes.
Declaration
public Stream DataStream { get; }
Property Value
Type | Description |
---|---|
Stream | The contents as a stream of bytes. |
Id
The unique ID of the data.
Declaration
[DataMember]
public Cid Id { get; set; }
Property Value
Type | Description |
---|---|
Cid | A Cid of the content. |
Links
Declaration
[DataMember]
public IEnumerable<IMerkleLink> Links { get; }
Property Value
Type | Description |
---|---|
IEnumerable<IMerkleLink> |
Size
The serialised size in bytes of the node.
Declaration
[DataMember]
public long Size { get; }
Property Value
Type | Description |
---|---|
Int64 |
Methods
| Improve this Doc View SourceAddLink(IMerkleLink)
Adds a link.
Declaration
public DagNode AddLink(IMerkleLink link)
Parameters
Type | Name | Description |
---|---|---|
IMerkleLink | link | The link to add. |
Returns
Type | Description |
---|---|
DagNode | A new DagNode with the existing and new links. |
Remarks
A DagNode is immutable.
AddLinks(IEnumerable<IMerkleLink>)
Adds a sequence of links.
Declaration
public DagNode AddLinks(IEnumerable<IMerkleLink> links)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<IMerkleLink> | links | The sequence of links to add. |
Returns
Type | Description |
---|---|
DagNode | A new DagNode with the existing and new links. |
Remarks
A DagNode is immutable.
RemoveLink(IMerkleLink)
Removes a link.
Declaration
public DagNode RemoveLink(IMerkleLink link)
Parameters
Type | Name | Description |
---|---|---|
IMerkleLink | link | The IMerkleLink to remove. |
Returns
Type | Description |
---|---|
DagNode | A new DagNode with the |
Remarks
A DagNode is immutable.
No exception is raised if the link
does
not exist.
RemoveLinks(IEnumerable<IMerkleLink>)
Remove a sequence of links.
Declaration
public DagNode RemoveLinks(IEnumerable<IMerkleLink> links)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<IMerkleLink> | links | The sequence of IMerkleLink to remove. |
Returns
Type | Description |
---|---|
DagNode | A new DagNode with the |
Remarks
A DagNode is immutable.
No exception is raised if any of the links
do
not exist.
ToArray()
Returns the IPFS binary representation as a byte array.
Declaration
public byte[] ToArray()
Returns
Type | Description |
---|---|
Byte[] | A byte array. |
ToLink(String)
Declaration
public IMerkleLink ToLink(string name = "")
Parameters
Type | Name | Description |
---|---|---|
String | name |
Returns
Type | Description |
---|---|
IMerkleLink |
Write(CodedOutputStream)
Writes the binary representation of the node 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. |
Write(Stream)
Writes the binary representation of the node to the specified Stream.
Declaration
public void Write(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The Stream to write to. |