1 #ifndef IPFS_TRUSTLESS_REQUEST_H_
2 #define IPFS_TRUSTLESS_REQUEST_H_
4 #include "gateway_request_type.h"
6 #include <ipfs_client/ipld/block_source.h>
7 #include <ipfs_client/cid.h>
8 #include <ipfs_client/client.h>
10 #include <vocab/slash_delimited.h>
16 #include <unordered_set>
30 std::string_view name(GatewayRequestType);
32 constexpr std::size_t BLOCK_RESPONSE_BUFFER_SIZE = 2UL * 1024UL * 1024UL;
33 constexpr std::size_t CAR_RESPONSE_BUFFER_SIZE = 5UL * 1024UL * 1024UL;
47 std::optional<Cid> cid_;
48 std::shared_ptr<Partition> orchestrator_;
49 std::vector<BytesReceivedHook> bytes_received_hooks;
50 std::string main_param;
54 void AddBlock(std::string_view bytes,
57 std::shared_ptr<Client>
const& api,
59 void AddBlocks(
Car& car,
60 std::shared_ptr<Client>
const& api,
62 bool IpnsResponse(ByteView bytes, std::shared_ptr<Client>
const& api,
bool& success,
bool* valid,
ipld::BlockSource src);
65 GatewayRequestType type = GatewayRequestType::Zombie;
69 std::shared_ptr<IpfsRequest> dependent;
72 std::unordered_set<std::string> failures;
74 std::optional<Cid>
const& cid()
const;
76 std::string url_suffix()
const;
77 std::string_view accept()
const;
78 std::string_view identity_data()
const;
79 short timeout_seconds()
const;
81 std::optional<std::size_t> max_response_size()
const;
82 std::optional<HttpRequestDescription> describe_http(std::string_view)
const;
83 std::string debug_string()
const;
84 void orchestrator(std::shared_ptr<Partition>
const&);
85 bool cachable()
const;
92 bool RespondSuccessfully(std::string_view,
93 std::shared_ptr<Client>
const& api,
95 std::string_view roots =
"",
96 bool* valid =
nullptr);
98 bool PartiallyRedundant()
const;
99 std::string Key()
const;
100 bool Finished()
const;
102 static std::shared_ptr<GatewayRequest> fromIpfsPath(
SlashDelimited ipfs_path);
107 inline std::ostream& operator<<(std::ostream& s,
108 ipfs::gw::GatewayRequestType t) {
Definition: gateway_request.h:39
std::string_view root_component() const
std::function< void(std::string_view, ByteView, ipld::BlockSource const &)> BytesReceivedHook
Definition: gateway_request.h:44
std::string path
For CAR requests.
Definition: gateway_request.h:68
Definition: slash_delimited.h:15
Definition: block_source.h:12