22 #ifndef __PERCYCLIENT_H__
23 #define __PERCYCLIENT_H__
29 #include "percyresult.h"
31 #include "percystats.h"
51 nservers_t
num_servers, nservers_t
t, sid_t * sids = NULL,
60 nqueries_t querybsize = 1);
70 std::vector<ostream*> &osvec,
bool send_num_queries =
true);
78 std::vector<istream*> &isvec);
97 bool get_result (nqueries_t request_identifier,
98 vector<PercyBlockResults> & results);
115 vector<dbsize_t> block_numbers, vector<ostream*> &osvec,
116 vector<istream*> &isvec, vector<PercyBlockResults> &results,
117 nqueries_t querybsize = 1);
126 return requested_blocks[request_identifier];
134 nqueries_t
get_qbs (nqueries_t request_identifier) {
135 return blocks_per_query[request_identifier];
150 vector<ostream*> &osvec,
bool send_num_queries =
true) = 0;
158 vector<istream*> &isvec) = 0;
166 vector<vector<PercyResult> >& results) = 0;
193 typedef map<nqueries_t, vector<dbsize_t> > BlockNumbers;
194 typedef map<nqueries_t, vector<PercyBlockResults> > BlockResults;
195 enum RequestStatus { ENCODE, SEND, RECEIVE, DECODE, INCOMPLETE, DONE };
196 typedef map<nqueries_t, RequestStatus> RequestStatuses;
198 nqueries_t next_request_identifier;
199 BlockNumbers requested_blocks;
200 std::map<nqueries_t, nqueries_t> blocks_per_query;
201 RequestStatuses statuses;
202 BlockNumbers undecoded_blocks;
203 BlockResults decoded_blocks;
206 map<nqueries_t, nqueries_t> request_id_to_stats_batch_number;
209 inline ostream& operator<<(ostream &out, vector<dbsize_t> v) {
211 for (vector<dbsize_t>::const_iterator i=v.begin();
Client parameters.
Definition: percyparams.h:189
vector< nservers_t > goodservers
The server indices of servers that have not acted up.
Definition: percyclient.h:188
Definition: percystats.h:66
const PercyClientParams * clientparams
Parameters for the client.
Definition: percyclient.h:181
bool fetch_blocks(nqueries_t &request_identifier, vector< dbsize_t > block_numbers, vector< ostream * > &osvec, vector< istream * > &isvec, vector< PercyBlockResults > &results, nqueries_t querybsize=1)
Do encode_request(), send_request(), receive_replies(), process_replies(), and get_result() all in on...
virtual dbsize_t receive_replies_impl(nqueries_t request_identifier, vector< istream * > &isvec)=0
Implementation for encode_request().
PercyClient(const PercyClientParams *clientparams, nservers_t num_servers, nservers_t t, PercyStats *stats=NULL)
Constructor.
dbsize_t send_request(nqueries_t request_identifier, std::vector< ostream * > &osvec, bool send_num_queries=true)
Send the request for the given request ID.
bool get_result(nqueries_t request_identifier, vector< PercyBlockResults > &results)
Get the result for a given request ID.
static const bool randomize
Randomize the requests for IT-PIR clients.
Definition: percyclient.h:190
nservers_t t
The privacy level.
Definition: percyclient.h:186
A PIR client for recursive PIR protocols.
Definition: recursiveclient.h:30
virtual nqueries_t process_replies_impl(nservers_t h, vector< vector< PercyResult > > &results)=0
Implementation for encode_request().
nqueries_t process_replies(nservers_t h)
Process the servers' replies for all undecoded replies.
static PercyClient * make_client(const PercyClientParams *clientparams, nservers_t num_servers, nservers_t t, sid_t *sids=NULL, PercyStats *stats=NULL)
Factory method called to get a client object for the given parameters.
const vector< dbsize_t > & get_block_numbers(nqueries_t request_identifier)
Get the block numbers for a given request ID.
Definition: percyclient.h:125
nservers_t num_servers
The number of servers.
Definition: percyclient.h:183
dbsize_t receive_replies(nqueries_t request_identifier, std::vector< istream * > &isvec)
Receive the servers' replies for a given request ID.
nqueries_t encode_request(vector< dbsize_t > block_numbers, nqueries_t querybsize=1)
Encode a request for the given block numbers.
nqueries_t get_qbs(nqueries_t request_identifier)
Get the number of blocks to request in a single query for a given request ID.
Definition: percyclient.h:134
virtual ~PercyClient()
Destructor.
virtual void encode_request_impl(nqueries_t request_identifier)=0
Implementation for encode_request().
An abstract base class for a PIR client.
Definition: percyclient.h:35
virtual dbsize_t send_request_impl(nqueries_t request_identifier, vector< ostream * > &osvec, bool send_num_queries=true)=0
Implementation for send_request().
Defines the basic structure of protocol parameters (PercyParams), client parameters (PercyClientParam...