From c53da67e1a0c8ed5e113b1708dcf5132cbe06323 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Mon, 9 May 2022 20:28:13 +0200 Subject: [PATCH] added BEGIN_BOOST_SERIALIZATION macros --- src/common/boost_serialization_helper.h | 1 + src/common/boost_serialization_maps.h | 32 +++++++++++++++++++++++ src/currency_core/currency_basic.h | 2 +- src/currency_core/currency_config.h | 1 + src/currency_core/currency_format_utils.h | 2 ++ src/wallet/wallet2.h | 1 + 6 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 src/common/boost_serialization_maps.h diff --git a/src/common/boost_serialization_helper.h b/src/common/boost_serialization_helper.h index 5ad68a05..1f2297a4 100644 --- a/src/common/boost_serialization_helper.h +++ b/src/common/boost_serialization_helper.h @@ -16,6 +16,7 @@ #define CHECK_PROJECT_NAME() std::string project_name = CURRENCY_NAME; ar & project_name; if(!(project_name == CURRENCY_NAME) ) {throw std::runtime_error(std::string("wrong storage file: project name in file: ") + project_name + ", expected: " + CURRENCY_NAME );} + namespace tools { template diff --git a/src/common/boost_serialization_maps.h b/src/common/boost_serialization_maps.h new file mode 100644 index 00000000..bd8436d9 --- /dev/null +++ b/src/common/boost_serialization_maps.h @@ -0,0 +1,32 @@ +// Copyright (c) 2014-2022 Zano Project +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#pragma once + +#define BEGIN_BOOST_SERIALIZATION() template inline void serialize(t_archive &_arch, const unsigned int ver) { + +#define BOOST_SERIALIZE(x) _arch & x; + +#define END_BOOST_SERIALIZATION() } + + +/* + example of use: + + struct tx_extra_info + { + crypto::public_key m_tx_pub_key; + extra_alias_entry m_alias; + std::string m_user_data_blob; + extra_attachment_info m_attachment_info; + + BEGIN_BOOST_SERIALIZATION() + BOOST_SERIALIZE(m_tx_pub_key) + BOOST_SERIALIZE(m_alias) + if(ver < xxx) return; + BOOST_SERIALIZE(m_user_data_blob) + BOOST_SERIALIZE(m_attachment_info) + END_BOOST_SERIALIZATION() + }; +*/ diff --git a/src/currency_core/currency_basic.h b/src/currency_core/currency_basic.h index 99cd0f96..776074e4 100644 --- a/src/currency_core/currency_basic.h +++ b/src/currency_core/currency_basic.h @@ -602,7 +602,7 @@ namespace currency //extra std::vector extra; std::vector vin; - std::vector vout; + std::vector vout_;//std::vector vout; BEGIN_SERIALIZE() VARINT_FIELD(version) diff --git a/src/currency_core/currency_config.h b/src/currency_core/currency_config.h index 18e38c67..5cd97470 100644 --- a/src/currency_core/currency_config.h +++ b/src/currency_core/currency_config.h @@ -27,6 +27,7 @@ #define CURRENCY_PUBLIC_AUDITABLE_INTEG_ADDRESS_BASE58_PREFIX 0x8a49 // auditable integrated addresses start with 'aiZX' #define CURRENCY_MINED_MONEY_UNLOCK_WINDOW 10 #define CURRENT_TRANSACTION_VERSION 1 +#define CURRENT_TRANSACTION_VERSION_HF4 2 #define HF1_BLOCK_MAJOR_VERSION 1 #define CURRENT_BLOCK_MAJOR_VERSION 2 diff --git a/src/currency_core/currency_format_utils.h b/src/currency_core/currency_format_utils.h index 725b39e1..8c67c8c6 100644 --- a/src/currency_core/currency_format_utils.h +++ b/src/currency_core/currency_format_utils.h @@ -156,6 +156,7 @@ namespace currency std::vector prepared_destinations; uint64_t expiration_time; crypto::public_key spend_pub_key; // only for validations + uint64_t tx_version; BEGIN_SERIALIZE_OBJECT() FIELD(unlock_time) @@ -171,6 +172,7 @@ namespace currency FIELD(prepared_destinations) FIELD(expiration_time) FIELD(spend_pub_key) + FIELD(tx_version) END_SERIALIZE() }; diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index e57ff79a..5539a778 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -697,6 +697,7 @@ namespace tools uint64_t get_top_block_height() const { return m_chain.get_top_block_height(); } + template inline void serialize(t_archive &a, const unsigned int ver) {