Show / Hide Table of Contents

Class DagNode

A node in the IPFS Merkle DAG.

Inheritance
Object
DagNode
Implements
IMerkleNode<IMerkleLink>
IDataBlock
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Object.ToString()
Namespace: Ipfs
Assembly: Ipfs.Core.dll
Syntax
[DataContract]
public class DagNode : IMerkleNode<IMerkleLink>, IDataBlock
Remarks

A DagNode has opaque DataBytes and a set of navigable Links.

Constructors

| Improve this Doc View Source

DagNode(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.

| Improve this Doc View Source

DagNode(Byte[], IEnumerable<IMerkleLink>, String)

Create a new instance of a DagNode with the specified DataBytes and Links

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.

| Improve this Doc View Source

DagNode(Stream)

Creates a new instance of the DagNode class from the specified 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 Source

DataBytes

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.

| Improve this Doc View Source

DataStream

Contents as a stream of bytes.

Declaration
public Stream DataStream { get; }
Property Value
Type Description
Stream

The contents as a stream of bytes.

| Improve this Doc View Source

Id

The unique ID of the data.

Declaration
[DataMember]
public Cid Id { get; set; }
Property Value
Type Description
Cid

A Cid of the content.

| Improve this Doc View Source

Links

Declaration
[DataMember]
public IEnumerable<IMerkleLink> Links { get; }
Property Value
Type Description
IEnumerable<IMerkleLink>
| Improve this Doc View Source

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 Source

AddLink(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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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 link removed.

Remarks

A DagNode is immutable.

No exception is raised if the link does not exist.

| Improve this Doc View Source

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 links removed.

Remarks

A DagNode is immutable.

No exception is raised if any of the links do not exist.

| 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.

| Improve this Doc View Source

ToLink(String)

Declaration
public IMerkleLink ToLink(string name = "")
Parameters
Type Name Description
String name
Returns
Type Description
IMerkleLink
| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

Implements

IMerkleNode<Link>
IDataBlock
  • Improve this Doc
  • View Source
Back to top Generated by DocFX