Class

DAGService

DAGService(options)

DAGService is a content-addressable store for adding, removing, and getting Merkle directed acyclic graphs (DAGs). A DAG service provides an API for creating and resolving IPLD nodes, making it possible for apps and services to integrate with the IPFS IPLD Merkle-forest. It satisfies the default IPLD interface: https://github.com/ipld/js-ipld.

Constructor

# new DAGService(options)

DAGService creates a new directed acyclic graph (DAG) service.
Parameters:
Name Type Description
options DAGOptions The set of parameters to use when initializing a DAG service. Must include a `blockService` entry.

View Source core/dagservice.ts, line 18

Classes

DAGService

Members

BlockService

# blockService

The underlying block service for adding, deleting, and retrieving blocks.

View Source core/dagservice.ts, line 229

AddOptions

# defaultOptions

A set of default parameters to use when adding an IPLD Node via the DAG service.

View Source core/dagservice.ts, line 223

Methods

# async get(cid)

get returns an IPLD node by its content identifier.
Parameters:
Name Type Description
cid CID The content identifier for the IPLD node that should be retrieved.

View Source core/dagservice.ts, line 83

# async generator getMany(cids)

getMany returns multiple IPLD nodes from an iterable of content identifiers.
Parameters:
Name Type Description
cids Iterable.<CID> The content identifiers for the IPLD nodes that should be retrieved.

View Source core/dagservice.ts, line 93

# async put(node, codec, options)

put encodes and adds an IPLD node using the specified codec.
Parameters:
Name Type Default Description
node any The deserialized IPLD node that should be added. Can be any value, object, Buffer, JSON, etc.
codec string | number dag-cbor A string representing the multicodec with which the IPLD node should be encoded. Can also be a numeric multicodec code for compatibility with js-ipld.
options AddOptions The specific parameters to use when encoding the input node.

View Source core/dagservice.ts, line 106

# async generator putMany(nodes, codec, options)

putMany encodes and adds multiple IPLD nodes using the specified codec.
Parameters:
Name Type Default Description
nodes Iterable.<any> The deserialized IPLD nodes that should be added.
codec string | number dag-cbor A string representing the multicodec with which the IPLD node should be encoded. Can also be a numeric multicodec code for compatibility with js-ipld.
options AddOptions The specific parameters to use when encoding the input node.

View Source core/dagservice.ts, line 132

# async remove(cid)

remove deletes an IPLD node from the local store.
Parameters:
Name Type Description
cid CID The content identifier for the IPLD node to be removed.

View Source core/dagservice.ts, line 146

# async generator removeMany(cids)

removeMany deletes multiple IPLD nodes from the local store. Throws an error if any of the Blocks can’t be removed. This operation is *not* atomic, some nodes might have already been removed.
Parameters:
Name Type Description
cids Iterable.<CID> The content identifiers for the IPLD nodes to be removed.

View Source core/dagservice.ts, line 157

# async generator resolve(cid, path)

resolve retrieves IPLD nodes along the path that is rooted at a given IPLD node.
Parameters:
Name Type Description
cid CID The content identifier at which to start resolving.
path string The path that should be resolved.

View Source core/dagservice.ts, line 29

# async generator tree(cid, offsetPath, options)

tree returns all the paths that can be resolved into.
Parameters:
Name Type Description
cid CID The ID to get the paths from
offsetPath string the path to start to retrieve the other paths from.
options object Currently only whether to get the paths recursively or not. If `recursive` is `false`, it will only resolve the paths of the given CID.

View Source core/dagservice.ts, line 49