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 {
15  using Clock = std::chrono::system_clock;
16 
19  struct Category {
20  std::string gateway_url;
21  gw::GatewayRequestType request_type = gw::GatewayRequestType::Zombie;
22  bool cached = false;
23  // Oddly github version of apple clang doesn't have string::<=>
24  // auto operator<=>(Category const&) const = default;
25  bool operator<(Category const& r) const {
26  if (cached != r.cached) {
27  return cached;
28  }
29  if (request_type != r.request_type) {
30  return request_type < r.request_type;
31  }
32  return gateway_url < r.gateway_url;
33  }
34  };
35  std::string cid; // or similar
36  Clock::time_point fetched_at = Clock::now();
37  Clock::duration load_duration = std::chrono::seconds(0);
38 
39  Category cat;
40 
41  void Deserialize(std::string_view);
42  std::string Serialize() const;
43 };
44 } // namespace ipfs::ipld
45 
46 #endif // IPFS_CHROMIUM_BLOCK_SOURCE_H
Definition: block_source.h:19
Definition: block_source.h:12
std::chrono::system_clock Clock
Definition: block_source.h:15