1#ifndef IPFS_DAG_NODE_H_
2#define IPFS_DAG_NODE_H_
5#include "resolution_state.h"
7#include <ipfs_client/gw/gateway_request.h>
8#include <ipfs_client/ipld/block_source.h>
10#include <ipfs_client/cid.h>
11#include <ipfs_client/response.h>
12#include <vocab/slash_delimited.h>
29struct ContentIdentifier;
33using NodePtr = std::shared_ptr<DagNode>;
49 template <
class Range>
51 : ipfs_abs_paths_(many.begin(), many.end()) {}
56enum class ProvenAbsent {};
65 std::variant<MoreDataNeeded, Response, ProvenAbsent, PathChange>;
69class DagNode :
public std::enable_shared_from_this<DagNode> {
70 Link* FindChild(std::string_view);
79 std::vector<std::pair<std::string, Link>>
links_;
80 std::shared_ptr<Client>
api_;
88 std::function<NodePtr(std::string_view)> gen_child);
96 std::string_view link_key,
97 std::string_view block_key);
108 static NodePtr fromBytes(std::shared_ptr<Client>
const& api,
111 static NodePtr fromBytes(std::shared_ptr<Client>
const& api,
113 std::string_view bytes);
114 static NodePtr fromBlock(
PbDag const&);
122 virtual NodePtr rooted();
125 virtual NodePtr deroot();
147 virtual bool expired()
const;
151 virtual bool PreferOver(
DagNode const& another)
const;
156 void set_api(std::shared_ptr<Client> api);
Something to which a CID may refer directly.
Definition pb_dag.h:24
A block, an IPNS record, etc.
Definition dag_node.h:69
std::shared_ptr< Client > api_
Definition dag_node.h:80
std::vector< std::pair< std::string, Link > > links_
Definition dag_node.h:79
Definition directory_shard.h:9
Definition dnslink_name.h:9
Definition ipns_name.h:11
Definition resolution_state.h:21
virtual IpnsName const * as_ipns() const
Definition dag_node.h:140
virtual DirShard * as_hamt()
Definition dag_node.h:137
Definition block_source.h:12
MoreDataNeeded(Range const &many)
Definition dag_node.h:50
MoreDataNeeded(std::string one)
Definition dag_node.h:45
std::vector< std::string > ipfs_abs_paths_
Definition dag_node.h:54