def getnextblock(self): #if no keys left to fetch, exit if (len(self.keys) == 0): print "done." self.client.close() return # setup the argument for the call to DHash arg = dhashgateway_prot.dhash_retrieve_arg() # get the next key from the array (id, level, off) = self.keys.pop() arg.blockID = id arg.ctype = dhash_types.DHASH_CONTENTHASH arg.options = 0 arg.guess = chord_types.bigint(0) # we time each fetch for diagnostics: record start time start = time.time() try: self.outstanding += 1 # the RPC client will call self.process when the block comes back res = self.client( dhashgateway_prot.DHASHPROC_RETRIEVE, arg, lambda x: self.process(start, arg, level, off, x)) if res is not None: # something went badly wrong sys.exit(-1) except RPC.UnpackException, e: print_exc()
def getnextblock (self): #if no keys left to fetch, exit if (len(self.keys) == 0): print "done." self.client.close() return # setup the argument for the call to DHash arg = dhashgateway_prot.dhash_retrieve_arg () # get the next key from the array (id, level, off) = self.keys.pop() arg.blockID = id arg.ctype = dhash_types.DHASH_CONTENTHASH arg.options = 0 arg.guess = chord_types.bigint(0) # we time each fetch for diagnostics: record start time start = time.time() try: self.outstanding += 1 # the RPC client will call self.process when the block comes back res = self.client (dhashgateway_prot.DHASHPROC_RETRIEVE, arg, lambda x: self.process(start, arg, level, off, x)) if res is not None: # something went badly wrong sys.exit (-1) except RPC.UnpackException, e: print_exc ()
def inject (self): arg = dhashgateway_prot.dhash_retrieve_arg () blk = make_block (data_size) sobj = sha.sha(blk) arg.blockID = bigint(sobj.digest()) arg.ctype = dhash_types.DHASH_CONTENTHASH arg.options = 0 arg.guess = bigint(0) start = time.time() try: self.outstanding += 1 res = self.client (dhashgateway_prot.DHASHPROC_RETRIEVE, arg, lambda x: self.process(start, arg, blk, x)) if res is not None: self.process (start, arg, res) except RPC.UnpackException, e: print_exc ()
def inject(self): arg = dhashgateway_prot.dhash_retrieve_arg() blk = make_block(data_size) sobj = sha.sha(blk) arg.blockID = bigint(sobj.digest()) arg.ctype = dhash_types.DHASH_CONTENTHASH arg.options = 0 arg.guess = bigint(0) start = time.time() try: self.outstanding += 1 res = self.client(dhashgateway_prot.DHASHPROC_RETRIEVE, arg, lambda x: self.process(start, arg, blk, x)) if res is not None: self.process(start, arg, res) except RPC.UnpackException, e: print_exc()
def inject (self): arg = dhashgateway_prot.dhash_retrieve_arg () #specify the content hash key corresponding to the block to be retrieved arg.blockID = self.key arg.ctype = dhash_types.DHASH_CONTENTHASH arg.options = 0 arg.guess = bigint(0) start = time.time() try: # invokes dhash gateway to fetch the block # when the block is fetched, self.process() will be invoked res = self.client (dhashgateway_prot.DHASHPROC_RETRIEVE, arg, lambda x: self.process(start, arg, x)) if res is not None: self.process (start, arg, res) except RPC.UnpackException, e: print_exc ()
def inject(self): arg = dhashgateway_prot.dhash_retrieve_arg() #specify the content hash key corresponding to the block to be retrieved arg.blockID = self.key arg.ctype = dhash_types.DHASH_CONTENTHASH arg.options = 0 arg.guess = bigint(0) start = time.time() try: # invokes dhash gateway to fetch the block # when the block is fetched, self.process() will be invoked res = self.client(dhashgateway_prot.DHASHPROC_RETRIEVE, arg, lambda x: self.process(start, arg, x)) if res is not None: self.process(start, arg, res) except RPC.UnpackException, e: print_exc()