From 2b1c3c77bba56dd06f89a1be2ff08ae2634dfb59 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Sat, 16 Oct 2021 22:41:18 +0200 Subject: [PATCH] fixed #71 --- src/currency_core/account.cpp | 3 +-- src/p2p/net_node.inl | 9 ++++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/currency_core/account.cpp b/src/currency_core/account.cpp index 97d9480e..def20255 100644 --- a/src/currency_core/account.cpp +++ b/src/currency_core/account.cpp @@ -70,8 +70,7 @@ namespace currency iv = *((crypto::chacha8_iv*)&pass_hash); crypto::chacha8(scr_data, src_length, key, iv, (char*)dst_data); } - - + //----------------------------------------------------------------- std::string account_base::get_seed_phrase(const std::string& password) const { if (m_keys_seed_binary.empty()) diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl index 5042548d..855afd93 100644 --- a/src/p2p/net_node.inl +++ b/src/p2p/net_node.inl @@ -65,7 +65,14 @@ namespace nodetool CHECK_AND_ASSERT_MES(r, false, "Failed to parse P2P_MAINTAINERS_PUB_KEY = " << P2P_MAINTAINERS_PUB_KEY); std::string state_file_path = m_config_folder + "/" + P2P_NET_DATA_FILENAME; - tools::unserialize_obj_from_file(*this, state_file_path); + boost::system::error_code ec = AUTO_VAL_INIT(ec); + std::time_t last_update_time = boost::filesystem::last_write_time(state_file_path, ec); + //let's assume that if p2p peer list file stored more then 2 weeks ago, + //then it outdated and we need to fetch peerlist from seed nodes + if (!ec && time(nullptr) - last_update_time < 86400 * 14) + { + tools::unserialize_obj_from_file(*this, state_file_path); + } //always use new id, to be able differ cloned computers m_config.m_peer_id = crypto::rand();