ipfs-chromium
partition.h
1 #ifndef IPFS_ORCHESTRATOR_H_
2 #define IPFS_ORCHESTRATOR_H_
3 
4 #include "ipfs_client/ipld/dag_node.h"
5 
6 #include <ipfs_client/gw/requestor.h>
7 #include <vocab/flat_mapset.h>
8 
9 #include <memory>
10 #include <string>
11 
12 namespace ipfs {
13 
14 class Client;
18 class Partition : public std::enable_shared_from_this<Partition> {
19  public:
20  using GatewayAccess =
21  std::function<void(std::shared_ptr<gw::GatewayRequest>)>;
22  using MimeDetection = std::function<
23  std::string(std::string, std::string_view, std::string const&)>;
24  void build_response(std::shared_ptr<IpfsRequest>);
25  bool add_node(std::string key, ipld::NodePtr);
26  bool has_key(std::string const& k) const;
27  std::size_t Stored() const { return dags_.size(); }
28 
29  explicit Partition(std::shared_ptr<gw::Requestor> requestor,
30  std::shared_ptr<Client>);
31 
32  private:
33  flat_map<std::string, ipld::NodePtr> dags_;
34  std::shared_ptr<Client> api_;
35  std::shared_ptr<gw::Requestor> requestor_;
36 
37  void from_tree(std::shared_ptr<IpfsRequest>,
38  ipld::NodePtr&,
40  std::string const&);
41  bool gw_request(std::shared_ptr<IpfsRequest>,
42  SlashDelimited path,
43  std::string const& aff);
44  std::string sniff(SlashDelimited, std::string const&) const;
45 };
46 } // namespace ipfs::ipld
47 
48 #endif // IPFS_ORCHESTRATOR_H_
Definition: partition.h:18
Definition: slash_delimited.h:15