1#ifndef joedb_rpc_Client_declared
2#define joedb_rpc_Client_declared
21 const std::vector<Signature> &signatures;
31 lock->write((
const char *)h.data(), h.size() *
sizeof h[0]);
32 lock->read(buffer.
data, 9);
36 if (buffer.
read<
char>() !=
'H')
38 session_id = buffer.
read<int64_t>();
53 signatures(signatures)
62 auto &signature = signatures[procedure_id];
66 const int64_t from = int64_t(signature.prolog.size());
67 const int64_t until = file.
get_size();
70 buffer.
write<
char>(
'C');
71 buffer.
write<int64_t>(procedure_id);
72 buffer.
write<int64_t>(until);
76 lock->write(file.
get_data().data() + from, until - from);
77 lock->read(buffer.
data, 9);
81 const char reply = buffer.
read<
char>();
85 const size_t from = file.
get_data().size();
86 const int64_t until = buffer.
read<int64_t>();
87 file.
get_data().resize(
size_t(until));
88 lock->read(file.
get_data().data() + from, size_t(until) - from);
89 file.
pwrite((
const char *)&until, 8, 0);
90 file.
pwrite((
const char *)&until, 8, 8);
94 const int64_t n = buffer.
read<int64_t>();
95 std::string error_message;
96 error_message.resize(n);
97 lock->read(error_message.data(), n);
char data[size+extra_size]
void pwrite(const char *buffer, size_t size, int64_t offset) override
Write a range of bytes. Extend file size if necessary.
int64_t get_size() const override
Get the size of the file, or -1 if it is unknown.
std::array< uint32_t, 8 > Hash
Client(Channel &channel, const std::vector< Signature > &signatures)
void call(int64_t procedure_id, Memory_File &file)
SHA_256::Hash get_hash(const std::vector< Signature > &signatures)
Compute hash code for a collection of procedure signatures.