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. |
Classes
Members
BlockService
# blockService
The underlying block service for adding, deleting, and retrieving blocks.
AddOptions
# defaultOptions
A set of default parameters to use when adding an IPLD Node via the DAG service.
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. |
# 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. |
# 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. |
# 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. |
# 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. |
# 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. |
# 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. |
# 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. |