aboutsummaryrefslogtreecommitdiff
path: root/src/p2p
diff options
context:
space:
mode:
authorkenshi84 <kenshi84@protonmail.ch>2016-12-20 13:04:19 +0900
committerkenshi84 <kenshi84@protonmail.ch>2016-12-20 13:04:19 +0900
commit2ac80075444ebac2feef59f98c912342a708606d (patch)
tree3c91949940c438dea8c53b62ae5b1ee16c3f0ad1 /src/p2p
parentmoved boost cpp into hpp since they're supposed to be header only (diff)
downloadmonero-2ac80075444ebac2feef59f98c912342a708606d.tar.xz
also use portable serializer for boost_serialization_helper.h and net_node.inl, completely adandon boost/archive/binary_oarchive.hpp
Diffstat (limited to '')
-rw-r--r--src/p2p/net_node.inl32
-rw-r--r--src/p2p/net_peerlist.h3
2 files changed, 28 insertions, 7 deletions
diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl
index 442c42517..f32e7a435 100644
--- a/src/p2p/net_node.inl
+++ b/src/p2p/net_node.inl
@@ -137,14 +137,34 @@ namespace nodetool
{
try
{
- boost::archive::binary_iarchive a(p2p_data);
+ // first try reading in portable mode
+ boost::archive::portable_binary_iarchive a(p2p_data);
a >> *this;
}
- catch (const std::exception &e)
+ catch (...)
{
- LOG_ERROR("Failed to load p2p config file, falling back to default config");
- m_peerlist = peerlist_manager(); // it was probably half clobbered by the failed load
- make_default_config();
+ // if failed, try reading in unportable mode
+ boost::filesystem::copy_file(state_file_path, state_file_path + ".unportable", boost::filesystem::copy_option::overwrite_if_exists);
+ p2p_data.close();
+ p2p_data.open( state_file_path , std::ios_base::binary | std::ios_base::in);
+ if(!p2p_data.fail())
+ {
+ try
+ {
+ boost::archive::binary_iarchive a(p2p_data);
+ a >> *this;
+ }
+ catch (const std::exception &e)
+ {
+ LOG_ERROR("Failed to load p2p config file, falling back to default config");
+ m_peerlist = peerlist_manager(); // it was probably half clobbered by the failed load
+ make_default_config();
+ }
+ }
+ else
+ {
+ make_default_config();
+ }
}
}else
{
@@ -645,7 +665,7 @@ namespace nodetool
return false;
};
- boost::archive::binary_oarchive a(p2p_data);
+ boost::archive::portable_binary_oarchive a(p2p_data);
a << *this;
return true;
CATCH_ENTRY_L0("blockchain_storage::save", false);
diff --git a/src/p2p/net_peerlist.h b/src/p2p/net_peerlist.h
index c19ecf65f..fa69abd6e 100644
--- a/src/p2p/net_peerlist.h
+++ b/src/p2p/net_peerlist.h
@@ -36,8 +36,9 @@
#include <boost/foreach.hpp>
//#include <boost/bimap.hpp>
//#include <boost/bimap/multiset_of.hpp>
-#include <boost/archive/binary_oarchive.hpp>
#include <boost/archive/binary_iarchive.hpp>
+#include <boost/archive/portable_binary_oarchive.hpp>
+#include <boost/archive/portable_binary_iarchive.hpp>
#include <boost/serialization/version.hpp>
#include <boost/multi_index_container.hpp>