Beispiel #1
0
    def _prepare_data_request(self, keys):
        req = KeyRequest()
        req.request_id = self._get_request_id()
        req.response_address = self.response_address

        tuples = []

        for key in keys:
            tup = req.tuples.add()
            tuples.append(tup)
            tup.key = key

            if self.address_cache and key in self.address_cache:
                tup.address_cache_size = len(self.address_cache[key])

        return (req, tuples)
Beispiel #2
0
    def _prepare_delta_data_request(self, keys, serialized_previous):
        req = KeyRequest()
        req.request_id = self._get_request_id()
        req.response_address = self.response_address

        tuples = []

        for key in keys:
            tup = req.tuples.add()
            tuples.append(tup)
            tup.key = key
            tup.previous_payload = serialized_previous
            tup.delta = True

            if self.address_cache and key in self.address_cache:
                tup.address_cache_size = len(self.address_cache[key])

        return (req, tuples)