39 #include <boost/archive/binary_iarchive.hpp> 40 #include <boost/archive/portable_binary_oarchive.hpp> 41 #include <boost/archive/portable_binary_iarchive.hpp> 42 #include <boost/serialization/version.hpp> 44 #include <boost/multi_index_container.hpp> 45 #include <boost/multi_index/ordered_index.hpp> 46 #include <boost/multi_index/identity.hpp> 47 #include <boost/multi_index/member.hpp> 48 #include <boost/range/adaptor/reversed.hpp> 52 #include "net/local_ip.h" 58 #define CURRENT_PEERLIST_STORAGE_ARCHIVE_VER 6 70 bool init(
bool allow_local_ip);
76 bool get_peerlist_full(std::list<peerlist_entry>& pl_gray, std::list<peerlist_entry>& pl_white);
129 typedef boost::multi_index_container<
131 boost::multi_index::indexed_by<
133 boost::multi_index::ordered_unique<boost::multi_index::tag<by_addr>, boost::multi_index::member<peerlist_entry,epee::net_utils::network_address,&peerlist_entry::adr> >,
135 boost::multi_index::ordered_non_unique<boost::multi_index::tag<by_time>, boost::multi_index::member<peerlist_entry,int64_t,&peerlist_entry::last_seen> >
139 typedef boost::multi_index_container<
141 boost::multi_index::indexed_by<
143 boost::multi_index::ordered_unique<boost::multi_index::tag<by_id>, boost::multi_index::member<peerlist_entry,uint64_t,&peerlist_entry::id> >,
145 boost::multi_index::ordered_unique<boost::multi_index::tag<by_addr>, boost::multi_index::member<peerlist_entry,epee::net_utils::network_address,&peerlist_entry::adr> >,
147 boost::multi_index::ordered_non_unique<boost::multi_index::tag<by_time>, boost::multi_index::member<peerlist_entry,int64_t,&peerlist_entry::last_seen> >
151 typedef boost::multi_index_container<
153 boost::multi_index::indexed_by<
155 boost::multi_index::ordered_unique<boost::multi_index::tag<by_addr>, boost::multi_index::member<anchor_peerlist_entry,epee::net_utils::network_address,&anchor_peerlist_entry::adr> >,
157 boost::multi_index::ordered_non_unique<boost::multi_index::tag<by_time>, boost::multi_index::member<anchor_peerlist_entry,int64_t,&anchor_peerlist_entry::first_seen> >
162 template <
class Archive,
class List,
class Element,
class t_version_type>
165 if (
typename Archive::is_saving())
167 uint64_t size = list.size();
187 template <
class Archive,
class t_version_type>
261 auto by_addr_it = pi.get<
by_addr>().find(x.adr);
262 if(by_addr_it == pi.get<
by_addr>().end())
276 sorted_index.erase(sorted_index.begin());
285 sorted_index.erase(sorted_index.begin());
310 p = *epee::misc_utils::move_it_backward(--by_time_index.end(), i);
322 p = *epee::misc_utils::move_it_backward(--by_time_index.end(), i);
330 if(address.is_loopback())
354 bs_head.push_back(vl);
366 pl_gray.push_back(vl);
372 pl_white.push_back(vl);
389 CATCH_ENTRY_L0(
"peerlist_manager::set_peer_just_seen()",
false);
419 CATCH_ENTRY_L0(
"peerlist_manager::append_with_peer_white()",
false);
448 CATCH_ENTRY_L0(
"peerlist_manager::append_with_peer_gray()",
false);
466 CATCH_ENTRY_L0(
"peerlist_manager::append_with_peer_anchor()",
false);
480 size_t random_index = crypto::rand<size_t>() %
m_peers_gray.size();
483 pe = *epee::misc_utils::move_it_backward(--by_time_index.end(), random_index);
487 CATCH_ENTRY_L0(
"peerlist_manager::get_random_gray_peer()",
false);
505 CATCH_ENTRY_L0(
"peerlist_manager::remove_from_peer_gray()",
false);
526 CATCH_ENTRY_L0(
"peerlist_manager::get_and_empty_anchor_peerlist()",
false);
544 CATCH_ENTRY_L0(
"peerlist_manager::remove_from_peer_anchor()",
false);
int64_t last_seen
Definition: p2p_protocol_defs.h:73
AddressType adr
Definition: p2p_protocol_defs.h:71
AddressType adr
Definition: p2p_protocol_defs.h:86
BOOST_CLASS_VERSION(nodetool::node_server< cryptonote::t_cryptonote_protocol_handler< cryptonote::core > >, 1)
#define P2P_DEFAULT_PEERS_IN_HANDSHAKE
Definition: cryptonote_config.h:120
peerid_type id
Definition: p2p_protocol_defs.h:72
time_t time
Definition: blockchain.cpp:89
Definition: p2p_protocol_defs.h:84
type
Definition: json.h:74
#define P2P_LOCAL_GRAY_PEERLIST_LIMIT
Definition: cryptonote_config.h:115
string a
Definition: MakeCryptoOps.py:15
criter reverse(citer it)
Definition: utils.cpp:16
void clear(std::string &pass) noexcept
Definition: password.cpp:169
#define P2P_LOCAL_WHITE_PEERLIST_LIMIT
Definition: cryptonote_config.h:114
Definition: p2p_protocol_defs.h:69
#define CURRENT_PEERLIST_STORAGE_ARCHIVE_VER
Definition: net_peerlist.h:58