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>
19 #include <string_view>
29 struct ContentIdentifier;
31 namespace ipfs::ipld {
33 using NodePtr = std::shared_ptr<DagNode>;
40 template <
class Range>
42 : ipfs_abs_paths_(many.begin(), many.end()) {}
43 std::vector<std::string> ipfs_abs_paths_;
44 bool insist_on_car =
false;
46 enum class ProvenAbsent {};
52 std::variant<MoreDataNeeded, Response, ProvenAbsent, PathChange>;
56 class DagNode :
public std::enable_shared_from_this<DagNode> {
57 Link* FindChild(std::string_view);
63 std::vector<std::pair<std::string, Link>> links_;
64 std::shared_ptr<Client>
api_;
72 std::function<NodePtr(std::string_view)> gen_child);
80 std::string_view link_key,
81 std::string_view block_key);
87 static NodePtr fromBytes(std::shared_ptr<Client>
const& api,
90 static NodePtr fromBytes(std::shared_ptr<Client>
const& api,
92 std::string_view bytes);
93 static NodePtr fromBlock(
PbDag const&);
97 virtual NodePtr rooted();
98 virtual NodePtr deroot();
101 virtual DnsLinkName const* as_dnslink()
const {
return nullptr; }
102 virtual DirShard* as_hamt() {
return nullptr; }
103 virtual IpnsName
const* as_ipns()
const {
return nullptr; }
105 virtual bool expired()
const;
106 virtual bool PreferOver(DagNode
const& another)
const;
108 void set_api(std::shared_ptr<Client>);
109 void source(BlockSource src) { source_ = src; }
Something to which a CID may refer directly.
Definition: pb_dag.h:24
A block, an IPNS record, etc.
Definition: dag_node.h:56
std::shared_ptr< Client > api_
Definition: dag_node.h:64
ResolveResult CallChild(ResolutionState &)
As before, but it might be possible to create on the fly if not known.
Definition: dag_node.cc:171
Definition: dnslink_name.h:9
Definition: resolution_state.h:21
Definition: block_storage.h:11
Definition: block_source.h:12
Definition: dag_node.h:38
Definition: dag_node.h:47