MCPcopy Create free account
hub / github.com/attermann/microReticulum / write_response_temp_file

Function write_response_temp_file

examples/nomadnet/src/main.cpp:226–238  ·  view source on GitHub ↗

Write the raw response bytes (which we couldn't parse cleanly) to a temp file. Returns the file path on success, empty string on failure. Used for the "compressed response" path — see on_request_failed().

Source from the content-addressed store, hash-verified

224// temp file. Returns the file path on success, empty string on failure.
225// Used for the "compressed response" path — see on_request_failed().
226static std::string write_response_temp_file(const RNS::Bytes& request_id,
227 const RNS::Bytes& payload) {
228 std::string filename = "/tmp/nomadnet_";
229 filename += request_id.toHex();
230 filename += ".bin";
231 FILE* f = fopen(filename.c_str(), "wb");
232 if (!f) return std::string();
233 if (payload.size() > 0) {
234 fwrite(payload.data(), 1, payload.size(), f);
235 }
236 fclose(f);
237 return filename;
238}
239
240void on_response(const RNS::RequestReceipt& receipt) {
241 const RNS::Bytes request_id = receipt.get_request_id();

Callers 1

on_responseFunction · 0.85

Calls 3

toHexMethod · 0.80
dataMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected