ipfs-chromium
block_source.h
1 #ifndef IPFS_CHROMIUM_BLOCK_SOURCE_H
2 #define IPFS_CHROMIUM_BLOCK_SOURCE_H
3 
4 #include <ipfs_client/gw/gateway_request_type.h>
5 
6 #include <chrono>
7 #include <string>
8 
9 namespace ipfs::ipld {
12 struct BlockSource {
13  using Clock = std::chrono::system_clock;
14 
17  struct Category {
18  std::string gateway_url;
19  gw::GatewayRequestType request_type = gw::GatewayRequestType::Zombie;
20  bool cached = false;
21  // Oddly github version of apple clang doesn't have string::<=>
22  // auto operator<=>(Category const&) const = default;
23  bool operator<(Category const& r) const {
24  if (cached != r.cached) {
25  return cached;
26  }
27  if (request_type != r.request_type) {
28  return request_type < r.request_type;
29  }
30  return gateway_url < r.gateway_url;
31  }
32  };
33  std::string cid; // or similar
34  Clock::time_point fetched_at = Clock::now();
35  Clock::duration load_duration = std::chrono::seconds(0);
36 
37  Category cat;
38 
39  void Deserialize(std::string_view);
40  std::string Serialize() const;
41 };
42 } // namespace ipfs::ipld
43 
44 #endif // IPFS_CHROMIUM_BLOCK_SOURCE_H
Definition: block_source.h:17
Definition: block_source.h:12