def trace_filter(self, from_block=None, to_block=None, from_addresses=None, to_addresses=None): ''' https://github.com/ethcore/parity/wiki/JSONRPC-trace-module#trace_filter TESTED ''' params = {} if from_block is not None: from_block = validate_block(from_block) params['fromBlock'] = from_block if to_block is not None: to_block = validate_block(to_block) params['toBlock'] = to_block if from_addresses is not None: if not isinstance(from_addresses, list): from_addresses = [from_addresses] params['fromAddress'] = from_addresses if to_addresses is not None: if not isinstance(to_addresses, list): to_addresses = [to_addresses] params['toAddress'] = to_addresses return self._call('trace_filter', [params])
def evaluate_mv(self): predicted_frame = np.zeros(self.previous.shape, np.uint8) motion_field = np.zeros((self.height // self.N, self.width // self.N, 2)) for block_idx, block_jdx in tqdm(list(itertools.product(range(0, self.height - self.N + 1, self.N), range(0, self.width - self.N + 1, self.N)))): min_diff = np.infty matching_block = np.zeros((self.N, self.N), np.uint8) dx, dy = (0, 0) for vy, vx in itertools.product(range(-self.R, self.R + self.N + 1), range(-self.R, self.R + self.N + 1)): valid, start_current_block, end_current_block, \ start_previous_block, end_previous_block = validate_block(block_idx, block_jdx, vy, vx, self.height, self.width, self.N) if valid is False: continue current_block = sub_block(self.current, start_current_block, end_current_block).astype(np.float32) previous_block = sub_block(self.previous, start_previous_block, end_previous_block).astype(np.float32) block_difference = np.sum(np.abs(current_block - previous_block)) if block_difference < min_diff: min_diff = block_difference matching_block = previous_block dx, dy = (vx, vy) predicted_frame[block_idx:block_idx+self.N, block_jdx:block_jdx+self.N] = matching_block motion_field[block_idx // self.N, block_jdx // self.N, 0] = dx motion_field[block_idx // self.N, block_jdx // self.N, 1] = dy return predicted_frame, motion_field
def trace_block(self, block=BLOCK_TAG_LATEST): ''' https://github.com/ethcore/parity/wiki/JSONRPC-trace-module#trace_block TESTED ''' block = validate_block(block) return self._call('trace_block', [block])
def eth_getBlockByNumber(self, block=BLOCK_TAG_LATEST, tx_objects=True): ''' https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getblockbynumber TESTED ''' block = validate_block(block) return self._call('eth_getBlockByNumber', [block, tx_objects])
def up_getUncleByBlockNumberAndIndex(self, block=BLOCK_TAG_LATEST, index=0): ''' https://github.com/ethereum/wiki/wiki/JSON-RPC#up_getunclebyblocknumberandindex TESTED ''' block = validate_block(block) return self._call('up_getUncleByBlockNumberAndIndex', [block, hex(index)])
def up_getUncleCountByBlockNumber(self, block=BLOCK_TAG_LATEST): ''' https://github.com/ethereum/wiki/wiki/JSON-RPC#up_getunclecountbyblocknumber TESTED ''' block = validate_block(block) return hex_to_dec(self._call('up_getUncleCountByBlockNumber', [block]))
def up_getBlockTransactionCountByNumber(self, block=BLOCK_TAG_LATEST): ''' https://github.com/ethereum/wiki/wiki/JSON-RPC#up_getblocktransactioncountbynumber TESTED ''' block = validate_block(block) return hex_to_dec(self._call('up_getBlockTransactionCountByNumber', [block]))
def up_getTransactionCount(self, address, block=BLOCK_TAG_LATEST): ''' https://github.com/ethereum/wiki/wiki/JSON-RPC#up_gettransactioncount TESTED ''' block = validate_block(block) return hex_to_dec(self._call('up_getTransactionCount', [address, block]))
def up_getStorageAt(self, address=None, position=0, block=BLOCK_TAG_LATEST): ''' https://github.com/ethereum/wiki/wiki/JSON-RPC#up_getstorageat TESTED ''' block = validate_block(block) return self._call('up_getStorageAt', [address, hex(position), block])
def up_getBalance(self, address=None, block=BLOCK_TAG_LATEST): ''' https://github.com/ethereum/wiki/wiki/JSON-RPC#up_getbalance TESTED ''' address = address or self.up_coinbase() block = validate_block(block) return hex_to_dec(self._call('up_getBalance', [address, block]))
def eth_getTransactionByBlockNumberAndIndex(self, block=BLOCK_TAG_LATEST, index=0): ''' https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_gettransactionbyblocknumberandindex TESTED ''' block = validate_block(block) return self._call('eth_getTransactionByBlockNumberAndIndex', [block, hex(index)])