def parse_bx_block_transactions_and_msg_tail(block_hash: Sha256Hash, bx_block: memoryview, offset: int, short_ids: List[int], block_offsets: BlockOffsets, tx_service: TransactionService, block_pieces: Deque[Union[bytearray, memoryview]]) -> \ Tuple[List[int], List[Sha256Hash], int]: has_missing, unknown_tx_sids, unknown_tx_hashes = tx_service.get_missing_transactions(short_ids) if has_missing: return unknown_tx_sids, unknown_tx_hashes, offset short_tx_index = 0 output_offset = offset while offset < block_offsets.short_id_offset: if bx_block[offset] == ont_constants.ONT_SHORT_ID_INDICATOR: try: sid = short_ids[short_tx_index] except IndexError: raise message_conversion_error.btc_block_decompression_error( block_hash, f"Message is improperly formatted, short id index ({short_tx_index}) " f"exceeded its array bounds (size: {len(short_ids)})" ) tx_hash, tx, _ = tx_service.get_transaction(sid) offset += ont_constants.ONT_SHORT_ID_INDICATOR_LENGTH short_tx_index += 1 else: tx_size = ont_messages_util.get_next_tx_size(bx_block, offset) tx = bx_block[offset:offset + tx_size] offset += tx_size assert tx is not None block_pieces.append(tx) output_offset += len(tx) # Add consensus payload tail and owner and signature to block_pieces offset = block_offsets.block_begin_offset + ont_constants.ONT_HASH_LEN + ont_constants.ONT_INT_LEN + 1 payload_tail_len, = struct.unpack_from("<L", bx_block, offset) offset += ont_constants.ONT_INT_LEN block_pieces.append(bx_block[offset: offset + payload_tail_len]) offset += payload_tail_len owner_and_signature_len, = struct.unpack_from("<L", bx_block, offset) offset += ont_constants.ONT_INT_LEN block_pieces.append(bx_block[offset: offset + owner_and_signature_len]) offset += owner_and_signature_len return unknown_tx_sids, unknown_tx_hashes, output_offset
def parse_bx_block_transactions( block_hash: Sha256Hash, bx_block: memoryview, offset: int, short_ids: List[int], block_offsets: BlockOffsets, tx_service: TransactionService, block_pieces: Deque[Union[bytearray, memoryview]] ) -> Tuple[List[int], List[Sha256Hash], int]: has_missing, unknown_tx_sids, unknown_tx_hashes = \ tx_service.get_missing_transactions(short_ids) if has_missing: return unknown_tx_sids, unknown_tx_hashes, offset short_tx_index = 0 output_offset = offset while offset < block_offsets.short_id_offset: if bx_block[offset] == btc_constants.BTC_SHORT_ID_INDICATOR: try: sid = short_ids[short_tx_index] except IndexError: raise message_conversion_error.btc_block_decompression_error( block_hash, f"Message is improperly formatted, short id index ({short_tx_index}) " f"exceeded its array bounds (size: {len(short_ids)})" ) tx_hash, tx, _ = tx_service.get_transaction(sid) offset += btc_constants.BTC_SHORT_ID_INDICATOR_LENGTH short_tx_index += 1 else: tx_size = btc_messages_util.get_next_tx_size(bx_block, offset) tx = bx_block[offset:offset + tx_size] offset += tx_size # pyre-fixme[6]: Expected `Union[bytearray, memoryview]` for 1st param but # got `Optional[Union[bytearray, memoryview]]`. block_pieces.append(tx) # pyre-fixme[6]: Expected `Sized` for 1st param but got # `Optional[Union[bytearray, memoryview]]`. output_offset += len(tx) return unknown_tx_sids, unknown_tx_hashes, output_offset