def convert_to_older_version( self, msg: AbstractInternalMessage) -> AbstractInternalMessage: msg_type = msg.MESSAGE_TYPE if msg_type not in self._MSG_TYPE_TO_OLD_MSG_CLASS_MAPPING: raise ValueError( f"Tried to convert unexpected new message type to v6: {msg_type}" ) msg = cast(TxServiceSyncTxsMessage, msg) txs_content_short_ids = msg.txs_content_short_ids() txs_content_short_ids_v6 = [ TxContentShortIdsV6(item.tx_hash, item.tx_content, item.short_ids) for item in txs_content_short_ids ] network_num = msg.network_num() return TxServiceSyncTxsMessageV6(network_num, txs_content_short_ids_v6)
def convert_from_older_version( self, msg: AbstractInternalMessage) -> AbstractInternalMessage: msg_type = msg.MESSAGE_TYPE if msg_type not in self._MSG_TYPE_TO_NEW_MSG_CLASS_MAPPING: raise ValueError( f"Tried to convert unexpected old message type to v6: {msg_type}" ) msg = cast(TxServiceSyncTxsMessageV6, msg) txs_content_short_ids_v6 = msg.txs_content_short_ids() txs_content_short_ids = [ TxContentShortIds( item.tx_hash, item.tx_content, item.short_ids, [TransactionFlag.NO_FLAGS for _ in item.short_ids]) for item in txs_content_short_ids_v6 ] network_num = msg.network_num() return TxServiceSyncTxsMessage(network_num, txs_content_short_ids)