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