diff --git a/src/common/atomics_boost_serialization.h b/src/common/atomics_boost_serialization.h new file mode 100644 index 00000000..e9aa9798 --- /dev/null +++ b/src/common/atomics_boost_serialization.h @@ -0,0 +1,32 @@ +// Copyright (c) 2014-2018 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 + +#include + +namespace boost +{ + namespace serialization + { + template + inline void save(Archive &a, const std::atomic &x, const boost::serialization::version_type ver) + { + a << x.load(); + } + + template + inline void load(Archive &a, std::atomic &x, const boost::serialization::version_type ver) + { + value_t s = AUTO_VAL_INIT(s); + a >> s; + x.store(s); + } + template + inline void serialize(Archive &a, std::atomic &x, const boost::serialization::version_type ver) + { + split_free(a, x, ver); + } + } +} diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 2f596686..3d3c8933 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -1242,7 +1242,7 @@ void wallet2::get_short_chain_history(std::list 1, error::wallet_internal_error, "Can't change wallet genesis block once the blockchain has been populated"); crypto::hash genesis_hash = get_block_hash(genesis); - if (get_blockchain_current_size() == 1 && m_blockchain[0] != genesis_hash) - WLT_LOG_L0("Changing genesis block for wallet " << m_account.get_public_address_str() << ":" << ENDL << " " << m_blockchain[0] << " -> " << genesis_hash); + if (get_blockchain_current_size() == 1 && m_genesis != genesis_hash) + WLT_LOG_L0("Changing genesis block for wallet " << m_account.get_public_address_str() << ":" << ENDL << " " << m_genesis << " -> " << genesis_hash); - m_blockchain.clear(); + //m_blockchain.clear(); - m_blockchain.push_back(genesis_hash); + //m_blockchain.push_back(genesis_hash); + m_genesis = genesis_hash; m_local_bc_size = 1; m_last_bc_timestamp = genesis.timestamp; @@ -4294,8 +4302,8 @@ void wallet2::process_genesis_if_needed(const currency::block& genesis) void wallet2::set_genesis(const crypto::hash& genesis_hash) { THROW_IF_TRUE_WALLET_EX(get_blockchain_current_size() != 1, error::wallet_internal_error, "Can't change wallet genesis hash once the blockchain has been populated"); - WLT_LOG_L0("Changing genesis hash for wallet " << m_account.get_public_address_str() << ":" << ENDL << " " << m_blockchain[0] << " -> " << genesis_hash); - m_blockchain[0] = genesis_hash; + WLT_LOG_L0("Changing genesis hash for wallet " << m_account.get_public_address_str() << ":" << ENDL << " " << m_genesis << " -> " << genesis_hash); + m_genesis = genesis_hash; } //---------------------------------------------------------------------------------------------------- void wallet2::print_tx_sent_message(const currency::transaction& tx, const std::string& description, uint64_t fee /* = UINT64_MAX */) diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index d0d71597..352abe3c 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -14,6 +14,7 @@ #include #include + #include "include_base_utils.h" #include "profile_tools.h" #include "sync_locked_object.h" @@ -26,6 +27,7 @@ #include "wallet_public_structs_defs.h" #include "currency_core/currency_format_utils.h" #include "common/unordered_containers_boost_serialization.h" +#include "common/atomics_boost_serialization.h" #include "storages/portable_storage_template_helper.h" #include "crypto/chacha8.h" #include "crypto/hash.h"