Monero
net_peerlist.h
Go to the documentation of this file.
1 // Copyright (c) 2014-2020, The Monero Project
2 //
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without modification, are
6 // permitted provided that the following conditions are met:
7 //
8 // 1. Redistributions of source code must retain the above copyright notice, this list of
9 // conditions and the following disclaimer.
10 //
11 // 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 // of conditions and the following disclaimer in the documentation and/or other
13 // materials provided with the distribution.
14 //
15 // 3. Neither the name of the copyright holder nor the names of its contributors may be
16 // used to endorse or promote products derived from this software without specific
17 // prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
20 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22 // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
27 // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 //
29 // Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
30 
31 #pragma once
32 
33 #include <iosfwd>
34 #include <list>
35 #include <string>
36 #include <vector>
37 
38 #include <boost/multi_index_container.hpp>
39 #include <boost/multi_index/ordered_index.hpp>
40 #include <boost/multi_index/identity.hpp>
41 #include <boost/multi_index/member.hpp>
42 #include <boost/optional/optional.hpp>
43 #include <boost/range/adaptor/reversed.hpp>
44 
45 
46 #include "crypto/crypto.h"
47 #include "cryptonote_config.h"
48 #include "net/enums.h"
49 #include "net/local_ip.h"
50 #include "p2p_protocol_defs.h"
51 #include "syncobj.h"
52 
53 namespace nodetool
54 {
56  {
57  std::vector<peerlist_entry> white;
58  std::vector<peerlist_entry> gray;
59  std::vector<anchor_peerlist_entry> anchor;
60  };
61 
63  {
64  public:
66  : m_types{}
67  {}
68 
70  static boost::optional<peerlist_storage> open(std::istream& src, const bool new_format);
71 
73  static boost::optional<peerlist_storage> open(const std::string& path);
74 
77 
78  ~peerlist_storage() noexcept;
79 
81  peerlist_storage& operator=(const peerlist_storage&) = delete;
82 
84  bool store(std::ostream& dest, const peerlist_types& other) const;
85 
87  bool store(const std::string& path, const peerlist_types& other) const;
88 
90  peerlist_types take_zone(epee::net_utils::zone zone);
91 
92  private:
94  };
95 
96  /************************************************************************/
97  /* */
98  /************************************************************************/
100  {
101  public:
102  bool init(peerlist_types&& peers, bool allow_local_ip);
103  size_t get_white_peers_count(){CRITICAL_REGION_LOCAL(m_peerlist_lock); return m_peers_white.size();}
104  size_t get_gray_peers_count(){CRITICAL_REGION_LOCAL(m_peerlist_lock); return m_peers_gray.size();}
105  bool merge_peerlist(const std::vector<peerlist_entry>& outer_bs, const std::function<bool(const peerlist_entry&)> &f = NULL);
106  bool get_peerlist_head(std::vector<peerlist_entry>& bs_head, bool anonymize, uint32_t depth = P2P_DEFAULT_PEERS_IN_HANDSHAKE);
107  void get_peerlist(std::vector<peerlist_entry>& pl_gray, std::vector<peerlist_entry>& pl_white);
108  void get_peerlist(peerlist_types& peers);
109  bool get_white_peer_by_index(peerlist_entry& p, size_t i);
110  bool get_gray_peer_by_index(peerlist_entry& p, size_t i);
111  template<typename F> bool foreach(bool white, const F &f);
112  void evict_host_from_white_peerlist(const peerlist_entry& pr);
113  bool append_with_peer_white(const peerlist_entry& pr);
114  bool append_with_peer_gray(const peerlist_entry& pr);
115  bool append_with_peer_anchor(const anchor_peerlist_entry& ple);
116  bool set_peer_just_seen(peerid_type peer, const epee::net_utils::network_address& addr, uint32_t pruning_seed, uint16_t rpc_port, uint32_t rpc_credits_per_hash);
117  bool is_host_allowed(const epee::net_utils::network_address &address);
118  bool get_random_gray_peer(peerlist_entry& pe);
119  bool remove_from_peer_gray(const peerlist_entry& pe);
120  bool get_and_empty_anchor_peerlist(std::vector<anchor_peerlist_entry>& apl);
121  bool remove_from_peer_anchor(const epee::net_utils::network_address& addr);
122  bool remove_from_peer_white(const peerlist_entry& pe);
123 
124  private:
125  struct by_time{};
126  struct by_id{};
127  struct by_addr{};
128 
130  {
131  modify_all_but_id(const peerlist_entry& ple):m_ple(ple){}
133  {
134  e.id = m_ple.id;
135  }
136  private:
138  };
139 
140  struct modify_all
141  {
142  modify_all(const peerlist_entry& ple):m_ple(ple){}
144  {
145  e = m_ple;
146  }
147  private:
149  };
150 
152  {
153  modify_last_seen(time_t last_seen):m_last_seen(last_seen){}
155  {
156  e.last_seen = m_last_seen;
157  }
158  private:
159  time_t m_last_seen;
160  };
161 
162 
163  typedef boost::multi_index_container<
165  boost::multi_index::indexed_by<
166  // access by peerlist_entry::net_adress
167  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> >,
168  // sort by peerlist_entry::last_seen<
169  boost::multi_index::ordered_non_unique<boost::multi_index::tag<by_time>, boost::multi_index::member<peerlist_entry,int64_t,&peerlist_entry::last_seen> >
170  >
172 
173  typedef boost::multi_index_container<
175  boost::multi_index::indexed_by<
176  // access by anchor_peerlist_entry::net_adress
177  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> >,
178  // sort by anchor_peerlist_entry::first_seen
179  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> >
180  >
182 
183  private:
184  void trim_white_peerlist();
185  void trim_gray_peerlist();
186 
187  friend class boost::serialization::access;
188  epee::critical_section m_peerlist_lock;
189  std::string m_config_folder;
191 
192 
196  };
197  //--------------------------------------------------------------------------------------------------
199  {
200  while(m_peers_gray.size() > P2P_LOCAL_GRAY_PEERLIST_LIMIT)
201  {
202  peers_indexed::index<by_time>::type& sorted_index=m_peers_gray.get<by_time>();
203  sorted_index.erase(sorted_index.begin());
204  }
205  }
206  //--------------------------------------------------------------------------------------------------
208  {
209  while(m_peers_white.size() > P2P_LOCAL_WHITE_PEERLIST_LIMIT)
210  {
211  peers_indexed::index<by_time>::type& sorted_index=m_peers_white.get<by_time>();
212  sorted_index.erase(sorted_index.begin());
213  }
214  }
215  //--------------------------------------------------------------------------------------------------
216  inline
217  bool peerlist_manager::merge_peerlist(const std::vector<peerlist_entry>& outer_bs, const std::function<bool(const peerlist_entry&)> &f)
218  {
219  CRITICAL_REGION_LOCAL(m_peerlist_lock);
220  for(const peerlist_entry& be: outer_bs)
221  {
222  if (!f || f(be))
223  append_with_peer_gray(be);
224  }
225  // delete extra elements
226  trim_gray_peerlist();
227  return true;
228  }
229  //--------------------------------------------------------------------------------------------------
230  inline
232  {
233  CRITICAL_REGION_LOCAL(m_peerlist_lock);
234  if(i >= m_peers_white.size())
235  return false;
236 
237  peers_indexed::index<by_time>::type& by_time_index = m_peers_white.get<by_time>();
238  p = *epee::misc_utils::move_it_backward(--by_time_index.end(), i);
239  return true;
240  }
241  //--------------------------------------------------------------------------------------------------
242  inline
244  {
245  CRITICAL_REGION_LOCAL(m_peerlist_lock);
246  if(i >= m_peers_gray.size())
247  return false;
248 
249  peers_indexed::index<by_time>::type& by_time_index = m_peers_gray.get<by_time>();
250  p = *epee::misc_utils::move_it_backward(--by_time_index.end(), i);
251  return true;
252  }
253  //--------------------------------------------------------------------------------------------------
254  inline
255  bool peerlist_manager::is_host_allowed(const epee::net_utils::network_address &address)
256  {
257  //never allow loopback ip
258  if(address.is_loopback())
259  return false;
260 
261  if(!m_allow_local_ip && address.is_local())
262  return false;
263 
264  return true;
265  }
266  //--------------------------------------------------------------------------------------------------
267  inline
268  bool peerlist_manager::get_peerlist_head(std::vector<peerlist_entry>& bs_head, bool anonymize, uint32_t depth)
269  {
270  CRITICAL_REGION_LOCAL(m_peerlist_lock);
271  peers_indexed::index<by_time>::type& by_time_index=m_peers_white.get<by_time>();
272  uint32_t cnt = 0;
273 
274  // picks a random set of peers within the whole set, rather pick the first depth elements.
275  // The intent is that if someone asks twice, they can't easily tell:
276  // - this address was not in the first list, but is in the second, so the only way this can be
277  // is if its last_seen was recently reset, so this means the target node recently had a new
278  // connection to that address
279  // - this address was in the first list, and not in the second, which means either the address
280  // was moved to the gray list (if it's not accessible, which the attacker can check if
281  // the address accepts incoming connections) or it was the oldest to still fit in the 250 items,
282  // so its last_seen is old.
283  //
284  // See Cao, Tong et al. "Exploring the Monero Peer-to-Peer Network". https://eprint.iacr.org/2019/411
285  //
286  const uint32_t pick_depth = anonymize ? m_peers_white.size() : depth;
287  bs_head.reserve(pick_depth);
288  for(const peers_indexed::value_type& vl: boost::adaptors::reverse(by_time_index))
289  {
290  if(cnt++ >= pick_depth)
291  break;
292 
293  bs_head.push_back(vl);
294  }
295 
296  if (anonymize)
297  {
298  std::shuffle(bs_head.begin(), bs_head.end(), crypto::random_device{});
299  if (bs_head.size() > depth)
300  bs_head.resize(depth);
301  for (auto &e: bs_head)
302  e.last_seen = 0;
303  }
304 
305  return true;
306  }
307  //--------------------------------------------------------------------------------------------------
308  template<typename F> inline
309  bool peerlist_manager::foreach(bool white, const F &f)
310  {
311  CRITICAL_REGION_LOCAL(m_peerlist_lock);
312  peers_indexed::index<by_time>::type& by_time_index = white ? m_peers_white.get<by_time>() : m_peers_gray.get<by_time>();
313  for(const peers_indexed::value_type& vl: boost::adaptors::reverse(by_time_index))
314  if (!f(vl))
315  return false;
316  return true;
317  }
318  //--------------------------------------------------------------------------------------------------
319  inline
320  bool peerlist_manager::set_peer_just_seen(peerid_type peer, const epee::net_utils::network_address& addr, uint32_t pruning_seed, uint16_t rpc_port, uint32_t rpc_credits_per_hash)
321  {
322  TRY_ENTRY();
323  CRITICAL_REGION_LOCAL(m_peerlist_lock);
324  //find in white list
325  peerlist_entry ple;
326  ple.adr = addr;
327  ple.id = peer;
328  ple.last_seen = time(NULL);
329  ple.pruning_seed = pruning_seed;
330  ple.rpc_port = rpc_port;
331  ple.rpc_credits_per_hash = rpc_credits_per_hash;
332  return append_with_peer_white(ple);
333  CATCH_ENTRY_L0("peerlist_manager::set_peer_just_seen()", false);
334  }
335  //--------------------------------------------------------------------------------------------------
336  inline
338  {
339  TRY_ENTRY();
340  if(!is_host_allowed(ple.adr))
341  return true;
342 
343  CRITICAL_REGION_LOCAL(m_peerlist_lock);
344  //find in white list
345  auto by_addr_it_wt = m_peers_white.get<by_addr>().find(ple.adr);
346  if(by_addr_it_wt == m_peers_white.get<by_addr>().end())
347  {
348  //put new record into white list
349  evict_host_from_white_peerlist(ple);
350  m_peers_white.insert(ple);
351  trim_white_peerlist();
352  }else
353  {
354  //update record in white list
355  peerlist_entry new_ple = ple;
356  if (by_addr_it_wt->pruning_seed && ple.pruning_seed == 0) // guard against older nodes not passing pruning info around
357  new_ple.pruning_seed = by_addr_it_wt->pruning_seed;
358  if (by_addr_it_wt->rpc_port && ple.rpc_port == 0) // guard against older nodes not passing RPC port around
359  new_ple.rpc_port = by_addr_it_wt->rpc_port;
360  new_ple.last_seen = by_addr_it_wt->last_seen; // do not overwrite the last seen timestamp, incoming peer list are untrusted
361  m_peers_white.replace(by_addr_it_wt, new_ple);
362  }
363  //remove from gray list, if need
364  auto by_addr_it_gr = m_peers_gray.get<by_addr>().find(ple.adr);
365  if(by_addr_it_gr != m_peers_gray.get<by_addr>().end())
366  {
367  m_peers_gray.erase(by_addr_it_gr);
368  }
369  return true;
370  CATCH_ENTRY_L0("peerlist_manager::append_with_peer_white()", false);
371  }
372  //--------------------------------------------------------------------------------------------------
373  inline
375  {
376  TRY_ENTRY();
377  if(!is_host_allowed(ple.adr))
378  return true;
379 
380  CRITICAL_REGION_LOCAL(m_peerlist_lock);
381  //find in white list
382  auto by_addr_it_wt = m_peers_white.get<by_addr>().find(ple.adr);
383  if(by_addr_it_wt != m_peers_white.get<by_addr>().end())
384  return true;
385 
386  //update gray list
387  auto by_addr_it_gr = m_peers_gray.get<by_addr>().find(ple.adr);
388  if(by_addr_it_gr == m_peers_gray.get<by_addr>().end())
389  {
390  //put new record into white list
391  m_peers_gray.insert(ple);
392  trim_gray_peerlist();
393  }else
394  {
395  //update record in gray list
396  peerlist_entry new_ple = ple;
397  if (by_addr_it_gr->pruning_seed && ple.pruning_seed == 0) // guard against older nodes not passing pruning info around
398  new_ple.pruning_seed = by_addr_it_gr->pruning_seed;
399  if (by_addr_it_gr->rpc_port && ple.rpc_port == 0) // guard against older nodes not passing RPC port around
400  new_ple.rpc_port = by_addr_it_gr->rpc_port;
401  new_ple.last_seen = by_addr_it_gr->last_seen; // do not overwrite the last seen timestamp, incoming peer list are untrusted
402  m_peers_gray.replace(by_addr_it_gr, new_ple);
403  }
404  return true;
405  CATCH_ENTRY_L0("peerlist_manager::append_with_peer_gray()", false);
406  }
407  //--------------------------------------------------------------------------------------------------
408  inline
410  {
411  TRY_ENTRY();
412 
413  CRITICAL_REGION_LOCAL(m_peerlist_lock);
414 
415  auto by_addr_it_anchor = m_peers_anchor.get<by_addr>().find(ple.adr);
416 
417  if(by_addr_it_anchor == m_peers_anchor.get<by_addr>().end()) {
418  m_peers_anchor.insert(ple);
419  }
420 
421  return true;
422 
423  CATCH_ENTRY_L0("peerlist_manager::append_with_peer_anchor()", false);
424  }
425  //--------------------------------------------------------------------------------------------------
426  inline
428  {
429  TRY_ENTRY();
430 
431  CRITICAL_REGION_LOCAL(m_peerlist_lock);
432 
433  if (m_peers_gray.empty()) {
434  return false;
435  }
436 
437  size_t random_index = crypto::rand_idx(m_peers_gray.size());
438 
439  peers_indexed::index<by_time>::type& by_time_index = m_peers_gray.get<by_time>();
440  pe = *epee::misc_utils::move_it_backward(--by_time_index.end(), random_index);
441 
442  return true;
443 
444  CATCH_ENTRY_L0("peerlist_manager::get_random_gray_peer()", false);
445  }
446  //--------------------------------------------------------------------------------------------------
447  inline
449  {
450  TRY_ENTRY();
451 
452  CRITICAL_REGION_LOCAL(m_peerlist_lock);
453 
454  peers_indexed::index_iterator<by_addr>::type iterator = m_peers_white.get<by_addr>().find(pe.adr);
455 
456  if (iterator != m_peers_white.get<by_addr>().end()) {
457  m_peers_white.erase(iterator);
458  }
459 
460  return true;
461 
462  CATCH_ENTRY_L0("peerlist_manager::remove_from_peer_white()", false);
463  }
464  //--------------------------------------------------------------------------------------------------
465  inline
467  {
468  TRY_ENTRY();
469 
470  CRITICAL_REGION_LOCAL(m_peerlist_lock);
471 
472  peers_indexed::index_iterator<by_addr>::type iterator = m_peers_gray.get<by_addr>().find(pe.adr);
473 
474  if (iterator != m_peers_gray.get<by_addr>().end()) {
475  m_peers_gray.erase(iterator);
476  }
477 
478  return true;
479 
480  CATCH_ENTRY_L0("peerlist_manager::remove_from_peer_gray()", false);
481  }
482  //--------------------------------------------------------------------------------------------------
483  inline
484  bool peerlist_manager::get_and_empty_anchor_peerlist(std::vector<anchor_peerlist_entry>& apl)
485  {
486  TRY_ENTRY();
487 
488  CRITICAL_REGION_LOCAL(m_peerlist_lock);
489 
490  auto begin = m_peers_anchor.get<by_time>().begin();
491  auto end = m_peers_anchor.get<by_time>().end();
492 
493  std::for_each(begin, end, [&apl](const anchor_peerlist_entry &a) {
494  apl.push_back(a);
495  });
496 
497  m_peers_anchor.get<by_time>().clear();
498 
499  return true;
500 
501  CATCH_ENTRY_L0("peerlist_manager::get_and_empty_anchor_peerlist()", false);
502  }
503  //--------------------------------------------------------------------------------------------------
504  inline
505  bool peerlist_manager::remove_from_peer_anchor(const epee::net_utils::network_address& addr)
506  {
507  TRY_ENTRY();
508 
509  CRITICAL_REGION_LOCAL(m_peerlist_lock);
510 
511  anchor_peers_indexed::index_iterator<by_addr>::type iterator = m_peers_anchor.get<by_addr>().find(addr);
512 
513  if (iterator != m_peers_anchor.get<by_addr>().end()) {
514  m_peers_anchor.erase(iterator);
515  }
516 
517  return true;
518 
519  CATCH_ENTRY_L0("peerlist_manager::remove_from_peer_anchor()", false);
520  }
521  //--------------------------------------------------------------------------------------------------
522 }
523 
static void init(std::string cache_filename)
Definition: blockchain_blackball.cpp:221
Definition: net_peerlist.h:100
bool get_gray_peer_by_index(peerlist_entry &p, size_t i)
Definition: net_peerlist.h:243
bool foreach(bool white, const F &f)
Definition: net_peerlist.h:309
std::string m_config_folder
Definition: net_peerlist.h:189
bool append_with_peer_anchor(const anchor_peerlist_entry &ple)
Definition: net_peerlist.h:409
boost::multi_index_container< peerlist_entry, boost::multi_index::indexed_by< 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 > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< by_time >, boost::multi_index::member< peerlist_entry, int64_t,&peerlist_entry::last_seen > > > > peers_indexed
Definition: net_peerlist.h:171
bool set_peer_just_seen(peerid_type peer, const epee::net_utils::network_address &addr, uint32_t pruning_seed, uint16_t rpc_port, uint32_t rpc_credits_per_hash)
Definition: net_peerlist.h:320
bool merge_peerlist(const std::vector< peerlist_entry > &outer_bs, const std::function< bool(const peerlist_entry &)> &f=NULL)
Definition: net_peerlist.h:217
bool get_and_empty_anchor_peerlist(std::vector< anchor_peerlist_entry > &apl)
Definition: net_peerlist.h:484
bool get_random_gray_peer(peerlist_entry &pe)
Definition: net_peerlist.h:427
bool remove_from_peer_white(const peerlist_entry &pe)
Definition: net_peerlist.h:448
bool append_with_peer_white(const peerlist_entry &pr)
Definition: net_peerlist.h:337
bool m_allow_local_ip
Definition: net_peerlist.h:190
void trim_gray_peerlist()
Definition: net_peerlist.h:198
bool append_with_peer_gray(const peerlist_entry &pr)
Definition: net_peerlist.h:374
boost::multi_index_container< anchor_peerlist_entry, boost::multi_index::indexed_by< 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 > >, 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 > > > > anchor_peers_indexed
Definition: net_peerlist.h:181
epee::critical_section m_peerlist_lock
Definition: net_peerlist.h:188
void trim_white_peerlist()
Definition: net_peerlist.h:207
size_t get_gray_peers_count()
Definition: net_peerlist.h:104
bool remove_from_peer_gray(const peerlist_entry &pe)
Definition: net_peerlist.h:466
bool remove_from_peer_anchor(const epee::net_utils::network_address &addr)
Definition: net_peerlist.h:505
bool get_peerlist_head(std::vector< peerlist_entry > &bs_head, bool anonymize, uint32_t depth=P2P_DEFAULT_PEERS_IN_HANDSHAKE)
Definition: net_peerlist.h:268
peers_indexed m_peers_white
Definition: net_peerlist.h:194
anchor_peers_indexed m_peers_anchor
Definition: net_peerlist.h:195
bool get_white_peer_by_index(peerlist_entry &p, size_t i)
Definition: net_peerlist.h:231
peers_indexed m_peers_gray
Definition: net_peerlist.h:193
size_t get_white_peers_count()
Definition: net_peerlist.h:103
bool is_host_allowed(const epee::net_utils::network_address &address)
Definition: net_peerlist.h:255
Definition: net_peerlist.h:63
static boost::optional< peerlist_storage > open(std::istream &src, const bool new_format)
Definition: net_peerlist.cpp:161
peerlist_types m_types
Definition: net_peerlist.h:93
peerlist_storage(peerlist_storage &&)=default
bool store(std::ostream &dest, const peerlist_types &other) const
Save peers from this and other in stream dest.
Definition: net_peerlist.cpp:225
peerlist_storage(const peerlist_storage &)=delete
peerlist_types take_zone(epee::net_utils::zone zone)
Definition: net_peerlist.cpp:250
~peerlist_storage() noexcept
Definition: net_peerlist.cpp:222
peerlist_storage()
Definition: net_peerlist.h:65
#define P2P_LOCAL_GRAY_PEERLIST_LIMIT
Definition: cryptonote_config.h:131
#define P2P_LOCAL_WHITE_PEERLIST_LIMIT
Definition: cryptonote_config.h:130
#define P2P_DEFAULT_PEERS_IN_HANDSHAKE
Definition: cryptonote_config.h:136
string a
Definition: MakeCryptoOps.py:15
const
Definition: build_protob.py:9
default
Definition: build_protob.py:9
std::enable_if< std::is_unsigned< T >::value, T >::type rand_idx(T sz)
Definition: crypto.h:191
Definition: cryptonote_format_utils.h:44
Definition: levin_notify.h:52
uint64_t peerid_type
Definition: p2p_protocol_defs.h:48
anchor_peerlist_entry_base< epee::net_utils::network_address > anchor_peerlist_entry
Definition: p2p_protocol_defs.h:119
peerlist_entry_base< epee::net_utils::network_address > peerlist_entry
Definition: p2p_protocol_defs.h:98
Definition: blockchain_ancestry.cpp:72
#define F(w, k)
Definition: sha512-blocks.c:61
CXA_THROW_INFO_T void(* dest)(void *))
Definition: stack_trace.cpp:90
Definition: crypto.h:172
Definition: p2p_protocol_defs.h:102
AddressType adr
Definition: p2p_protocol_defs.h:103
Definition: p2p_protocol_defs.h:72
uint32_t pruning_seed
Definition: p2p_protocol_defs.h:76
AddressType adr
Definition: p2p_protocol_defs.h:73
uint16_t rpc_port
Definition: p2p_protocol_defs.h:77
peerid_type id
Definition: p2p_protocol_defs.h:74
int64_t last_seen
Definition: p2p_protocol_defs.h:75
uint32_t rpc_credits_per_hash
Definition: p2p_protocol_defs.h:78
Definition: net_peerlist.h:127
Definition: net_peerlist.h:126
Definition: net_peerlist.h:125
Definition: net_peerlist.h:130
modify_all_but_id(const peerlist_entry &ple)
Definition: net_peerlist.h:131
void operator()(peerlist_entry &e)
Definition: net_peerlist.h:132
const peerlist_entry & m_ple
Definition: net_peerlist.h:137
Definition: net_peerlist.h:141
modify_all(const peerlist_entry &ple)
Definition: net_peerlist.h:142
void operator()(peerlist_entry &e)
Definition: net_peerlist.h:143
const peerlist_entry & m_ple
Definition: net_peerlist.h:148
Definition: net_peerlist.h:152
modify_last_seen(time_t last_seen)
Definition: net_peerlist.h:153
time_t m_last_seen
Definition: net_peerlist.h:159
void operator()(peerlist_entry &e)
Definition: net_peerlist.h:154
Definition: net_peerlist.h:56
std::vector< anchor_peerlist_entry > anchor
Definition: net_peerlist.h:59
std::vector< peerlist_entry > gray
Definition: net_peerlist.h:58
std::vector< peerlist_entry > white
Definition: net_peerlist.h:57
static __thread int depth
Definition: threadpool.cpp:34