def _enrich_transactions(self, transactions): transactions = [ self.transaction_mapper.dict_to_transaction(transaction) for transaction in transactions ] all_inputs = [transaction.inputs for transaction in transactions] flat_inputs = [input for inputs in all_inputs for input in inputs] for transaction_input_batch in dynamic_batch_iterator( flat_inputs, lambda: self.batch_size): input_transactions_map = self._get_input_transactions_as_map( transaction_input_batch) for input in transaction_input_batch: output = self._get_output_for_input(input, input_transactions_map) \ if input.spent_transaction_hash is not None else None if output is not None: input.required_signatures = output.required_signatures input.type = output.type input.addresses = output.addresses input.value = output.value for transaction in transactions: self.item_exporter.export_item( self.transaction_mapper.transaction_to_dict(transaction))
def _get_raw_transactions_by_hashes_batched(self, hashes): if hashes is None or len(hashes) == 0: return [] result = [] batch_size = 100 for batch in dynamic_batch_iterator(hashes, lambda: batch_size): result.extend(self._get_raw_transactions_by_hashes(batch)) return result
def execute(self, work_iterable, work_handler, total_items=None): self.progress_logger.start(total_items=total_items) for batch in dynamic_batch_iterator(work_iterable, lambda: self.batch_size): self.executor.submit(self._fail_safe_execute, work_handler, batch)