Dogecoin Core  1.14.2
P2P Digital Currency
net.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2016 The Bitcoin Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #ifndef BITCOIN_NET_H
7 #define BITCOIN_NET_H
8 
9 #include "addrdb.h"
10 #include "addrman.h"
11 #include "alert.h"
12 #include "amount.h"
13 #include "bloom.h"
14 #include "compat.h"
15 #include "hash.h"
16 #include "limitedmap.h"
17 #include "netaddress.h"
18 #include "protocol.h"
19 #include "random.h"
20 #include "streams.h"
21 #include "sync.h"
22 #include "uint256.h"
23 #include "threadinterrupt.h"
24 
25 #include <atomic>
26 #include <deque>
27 #include <stdint.h>
28 #include <thread>
29 #include <memory>
30 #include <condition_variable>
31 
32 #ifndef WIN32
33 #include <arpa/inet.h>
34 #endif
35 
36 #include <boost/filesystem/path.hpp>
37 #include <boost/foreach.hpp>
38 #include <boost/signals2/signal.hpp>
39 
40 class CAddrMan;
41 class CScheduler;
42 class CNode;
43 
44 namespace boost {
45  class thread_group;
46 } // namespace boost
47 
49 static const int PING_INTERVAL = 2 * 60;
51 static const int TIMEOUT_INTERVAL = 20 * 60;
53 static const int FEELER_INTERVAL = 120;
55 static const unsigned int MAX_INV_SZ = 50000;
57 static const unsigned int MAX_ADDR_TO_SEND = 1000;
59 static const unsigned int MAX_PROTOCOL_MESSAGE_LENGTH = 4 * 1000 * 1000;
61 static const unsigned int MAX_SUBVERSION_LENGTH = 256;
63 static const int MAX_OUTBOUND_CONNECTIONS = 8;
65 static const int MAX_ADDNODE_CONNECTIONS = 8;
67 static const bool DEFAULT_LISTEN = true;
69 #ifdef USE_UPNP
70 static const bool DEFAULT_UPNP = USE_UPNP;
71 #else
72 static const bool DEFAULT_UPNP = false;
73 #endif
75 static const size_t MAPASKFOR_MAX_SZ = MAX_INV_SZ;
77 static const size_t SETASKFOR_MAX_SZ = 2 * MAX_INV_SZ;
79 static const unsigned int DEFAULT_MAX_PEER_CONNECTIONS = 125;
81 static const uint64_t DEFAULT_MAX_UPLOAD_TARGET = 0;
83 static const uint64_t MAX_UPLOAD_TIMEFRAME = 60 * 60 * 24;
85 static const bool DEFAULT_BLOCKSONLY = false;
86 
87 static const bool DEFAULT_FORCEDNSSEED = false;
88 static const size_t DEFAULT_MAXRECEIVEBUFFER = 5 * 1000;
89 static const size_t DEFAULT_MAXSENDBUFFER = 1 * 1000;
90 
91 static const ServiceFlags REQUIRED_SERVICES = NODE_NETWORK;
92 
93 // NOTE: When adjusting this, update rpcnet:setban's help ("24h")
94 static const unsigned int DEFAULT_MISBEHAVING_BANTIME = 60 * 60 * 24; // Default 24-hour ban
95 
96 typedef int64_t NodeId;
97 
99 {
100  std::string strAddedNode;
103  bool fInbound;
104 };
105 
106 class CTransaction;
107 class CNodeStats;
108 class CClientUIInterface;
109 
111 {
112  CSerializedNetMsg() = default;
115  // No copying, only moves.
116  CSerializedNetMsg(const CSerializedNetMsg& msg) = delete;
118 
119  std::vector<unsigned char> data;
120  std::string command;
121 };
122 
123 
124 class CConnman
125 {
126 public:
127 
130  CONNECTIONS_IN = (1U << 0),
131  CONNECTIONS_OUT = (1U << 1),
133  };
134 
135  struct Options
136  {
140  int nMaxOutbound = 0;
141  int nMaxAddnode = 0;
142  int nMaxFeeler = 0;
143  int nBestHeight = 0;
145  unsigned int nSendBufferMaxSize = 0;
146  unsigned int nReceiveFloodSize = 0;
147  uint64_t nMaxOutboundTimeframe = 0;
148  uint64_t nMaxOutboundLimit = 0;
149  };
150  CConnman(uint64_t seed0, uint64_t seed1);
151  ~CConnman();
152  bool Start(CScheduler& scheduler, std::string& strNodeError, Options options);
153  void Stop();
154  void Interrupt();
155  bool BindListenPort(const CService &bindAddr, std::string& strError, bool fWhitelisted = false);
156  bool GetNetworkActive() const { return fNetworkActive; };
157  void SetNetworkActive(bool active);
158  bool OpenNetworkConnection(const CAddress& addrConnect, bool fCountFailure, CSemaphoreGrant *grantOutbound = NULL, const char *strDest = NULL, bool fOneShot = false, bool fFeeler = false, bool fAddnode = false);
159  bool CheckIncomingNonce(uint64_t nonce);
160 
161  bool ForNode(NodeId id, std::function<bool(CNode* pnode)> func);
162 
163  void PushMessage(CNode* pnode, CSerializedNetMsg&& msg);
164 
165  template<typename Callable>
166  void ForEachNode(Callable&& func)
167  {
168  LOCK(cs_vNodes);
169  for (auto&& node : vNodes) {
170  if (NodeFullyConnected(node))
171  func(node);
172  }
173  };
174 
175  template<typename Callable>
176  void ForEachNode(Callable&& func) const
177  {
178  LOCK(cs_vNodes);
179  for (auto&& node : vNodes) {
180  if (NodeFullyConnected(node))
181  func(node);
182  }
183  };
184 
185  template<typename Callable, typename CallableAfter>
186  void ForEachNodeThen(Callable&& pre, CallableAfter&& post)
187  {
188  LOCK(cs_vNodes);
189  for (auto&& node : vNodes) {
190  if (NodeFullyConnected(node))
191  pre(node);
192  }
193  post();
194  };
195 
196  template<typename Callable, typename CallableAfter>
197  void ForEachNodeThen(Callable&& pre, CallableAfter&& post) const
198  {
199  LOCK(cs_vNodes);
200  for (auto&& node : vNodes) {
201  if (NodeFullyConnected(node))
202  pre(node);
203  }
204  post();
205  };
206 
207  // Addrman functions
208  size_t GetAddressCount() const;
209  void SetServices(const CService &addr, ServiceFlags nServices);
210  void MarkAddressGood(const CAddress& addr);
211  void AddNewAddress(const CAddress& addr, const CAddress& addrFrom, int64_t nTimePenalty = 0);
212  void AddNewAddresses(const std::vector<CAddress>& vAddr, const CAddress& addrFrom, int64_t nTimePenalty = 0);
213  std::vector<CAddress> GetAddresses();
215 
216  // Denial-of-service detection/prevention
217  // The idea is to detect peers that are behaving
218  // badly and disconnect/ban them, but do it in a
219  // one-coding-mistake-won't-shatter-the-entire-network
220  // way.
221  // IMPORTANT: There should be nothing I can give a
222  // node that it will forward on that will make that
223  // node's peers drop it. If there is, an attacker
224  // can isolate a node and/or try to split the network.
225  // Dropping a node for sending stuff that is invalid
226  // now but might be valid in a later version is also
227  // dangerous, because it can cause a network split
228  // between nodes running old code and nodes running
229  // new code.
230  void Ban(const CNetAddr& netAddr, const BanReason& reason, int64_t bantimeoffset = 0, bool sinceUnixEpoch = false);
231  void Ban(const CSubNet& subNet, const BanReason& reason, int64_t bantimeoffset = 0, bool sinceUnixEpoch = false);
232  void ClearBanned(); // needed for unit testing
233  bool IsBanned(CNetAddr ip);
234  bool IsBanned(CSubNet subnet);
235  bool Unban(const CNetAddr &ip);
236  bool Unban(const CSubNet &ip);
237  void GetBanned(banmap_t &banmap);
238  void SetBanned(const banmap_t &banmap);
239 
240  void AddOneShot(const std::string& strDest);
241 
242  bool AddNode(const std::string& node);
243  bool RemoveAddedNode(const std::string& node);
244  std::vector<AddedNodeInfo> GetAddedNodeInfo();
245 
246  size_t GetNodeCount(NumConnections num);
247  void GetNodeStats(std::vector<CNodeStats>& vstats);
248  bool DisconnectNode(const std::string& node);
249  bool DisconnectNode(NodeId id);
250 
251  unsigned int GetSendBufferSize() const;
252 
253  void AddWhitelistedRange(const CSubNet &subnet);
254 
256 
258  void SetMaxOutboundTarget(uint64_t limit);
259  uint64_t GetMaxOutboundTarget();
260 
262  void SetMaxOutboundTimeframe(uint64_t timeframe);
263  uint64_t GetMaxOutboundTimeframe();
264 
266  // if param historicalBlockServingLimit is set true, the function will
267  // response true if the limit for serving historical blocks has been reached
268  bool OutboundTargetReached(bool historicalBlockServingLimit);
269 
271  // in case of no limit, it will always response 0
272  uint64_t GetOutboundTargetBytesLeft();
273 
275  // in case of no limit, it will always response 0
277 
278  uint64_t GetTotalBytesRecv();
279  uint64_t GetTotalBytesSent();
280 
281  void SetBestHeight(int height);
282  int GetBestHeight() const;
283 
285  CSipHasher GetDeterministicRandomizer(uint64_t id) const;
286 
287  unsigned int GetReceiveFloodSize() const;
288 
289  void WakeMessageHandler();
290 private:
291  struct ListenSocket {
294 
295  ListenSocket(SOCKET socket_, bool whitelisted_) : socket(socket_), whitelisted(whitelisted_) {}
296  };
297 
299  void ProcessOneShot();
300  void ThreadOpenConnections();
301  void ThreadMessageHandler();
302  void AcceptConnection(const ListenSocket& hListenSocket);
303  void ThreadSocketHandler();
304  void ThreadDNSAddressSeed();
305 
306  uint64_t CalculateKeyedNetGroup(const CAddress& ad) const;
307 
308  CNode* FindNode(const CNetAddr& ip);
309  CNode* FindNode(const CSubNet& subNet);
310  CNode* FindNode(const std::string& addrName);
311  CNode* FindNode(const CService& addr);
312 
314  CNode* ConnectNode(CAddress addrConnect, const char *pszDest, bool fCountFailure);
315  bool IsWhitelistedRange(const CNetAddr &addr);
316 
317  void DeleteNode(CNode* pnode);
318 
320 
321  size_t SocketSendData(CNode *pnode) const;
323  bool BannedSetIsDirty();
325  void SetBannedSetDirty(bool dirty=true);
327  void SweepBanned();
328  void DumpAddresses();
329  void DumpData();
330  void DumpBanlist();
331 
332  // Network stats
333  void RecordBytesRecv(uint64_t bytes);
334  void RecordBytesSent(uint64_t bytes);
335 
336  // Whether the node should be passed out in ForEach* callbacks
337  static bool NodeFullyConnected(const CNode* pnode);
338 
339  // Network usage totals
342  uint64_t nTotalBytesRecv;
343  uint64_t nTotalBytesSent;
344 
345  // outbound limit & stats
350 
351  // Whitelisted ranges. Any node connecting from these is automatically
352  // whitelisted (as well as those connecting to whitelisted binds).
353  std::vector<CSubNet> vWhitelistedRange;
355 
356  unsigned int nSendBufferMaxSize;
357  unsigned int nReceiveFloodSize;
358 
359  std::vector<ListenSocket> vhListenSocket;
360  std::atomic<bool> fNetworkActive;
366  std::deque<std::string> vOneShots;
368  std::vector<std::string> vAddedNodes;
370  std::vector<CNode*> vNodes;
371  std::list<CNode*> vNodesDisconnected;
373  std::atomic<NodeId> nLastNodeId;
374 
377 
380 
387  std::atomic<int> nBestHeight;
389 
391  const uint64_t nSeed0, nSeed1;
392 
395 
396  std::condition_variable condMsgProc;
397  std::mutex mutexMsgProc;
398  std::atomic<bool> flagInterruptMsgProc;
399 
401 
402  std::thread threadDNSAddressSeed;
403  std::thread threadSocketHandler;
406  std::thread threadMessageHandler;
407 };
408 extern std::unique_ptr<CConnman> g_connman;
409 void Discover(boost::thread_group& threadGroup);
410 void MapPort(bool fUseUPnP);
411 unsigned short GetListenPort();
412 bool BindListenPort(const CService &bindAddr, std::string& strError, bool fWhitelisted = false);
413 
415 {
416  typedef bool result_type;
417 
418  template<typename I>
419  bool operator()(I first, I last) const
420  {
421  while (first != last) {
422  if (!(*first)) return false;
423  ++first;
424  }
425  return true;
426  }
427 };
428 
429 // Signals for message handling
431 {
432  boost::signals2::signal<bool (CNode*, CConnman&, std::atomic<bool>&), CombinerAll> ProcessMessages;
433  boost::signals2::signal<bool (CNode*, CConnman&, std::atomic<bool>&), CombinerAll> SendMessages;
434  boost::signals2::signal<void (CNode*, CConnman&)> InitializeNode;
435  boost::signals2::signal<void (NodeId, bool&)> FinalizeNode;
436 };
437 
438 
440 
441 
442 enum
443 {
444  LOCAL_NONE, // unknown
445  LOCAL_IF, // address a local interface listens on
446  LOCAL_BIND, // address explicit bound to
447  LOCAL_UPNP, // address reported by UPnP
448  LOCAL_MANUAL, // address explicitly specified (-externalip=)
449 
450  LOCAL_MAX
451 };
452 
453 bool IsPeerAddrLocalGood(CNode *pnode);
454 void AdvertiseLocal(CNode *pnode);
455 void SetLimited(enum Network net, bool fLimited = true);
456 bool IsLimited(enum Network net);
457 bool IsLimited(const CNetAddr& addr);
458 bool AddLocal(const CService& addr, int nScore = LOCAL_NONE);
459 bool AddLocal(const CNetAddr& addr, int nScore = LOCAL_NONE);
460 bool RemoveLocal(const CService& addr);
461 bool SeenLocal(const CService& addr);
462 bool IsLocal(const CService& addr);
463 bool GetLocal(CService &addr, const CNetAddr *paddrPeer = NULL);
464 bool IsReachable(enum Network net);
465 bool IsReachable(const CNetAddr &addr);
466 CAddress GetLocalAddress(const CNetAddr *paddrPeer, ServiceFlags nLocalServices);
467 
468 
469 extern bool fDiscover;
470 extern bool fListen;
471 extern bool fRelayTxes;
472 
474 
476 extern std::string strSubVersion;
477 
479  int nScore;
480  int nPort;
481 };
482 
484 extern std::map<CNetAddr, LocalServiceInfo> mapLocalHost;
485 typedef std::map<std::string, uint64_t> mapMsgCmdSize; //command, total bytes
486 
488 {
489 public:
493  int64_t nLastSend;
494  int64_t nLastRecv;
495  int64_t nTimeConnected;
496  int64_t nTimeOffset;
497  std::string addrName;
498  int nVersion;
499  std::string cleanSubVer;
500  bool fInbound;
501  bool fAddnode;
503  uint64_t nSendBytes;
505  uint64_t nRecvBytes;
508  double dPingTime;
509  double dPingWait;
510  double dMinPing;
511  std::string addrLocal;
513 };
514 
515 
516 
517 
518 class CNetMessage {
519 private:
520  mutable CHash256 hasher;
522 public:
523  bool in_data; // parsing header (false) or data (true)
524 
525  CDataStream hdrbuf; // partially received header
526  CMessageHeader hdr; // complete header
527  unsigned int nHdrPos;
528 
529  CDataStream vRecv; // received message data
530  unsigned int nDataPos;
531 
532  int64_t nTime; // time (in microseconds) of message receipt.
533 
534  CNetMessage(const CMessageHeader::MessageStartChars& pchMessageStartIn, int nTypeIn, int nVersionIn) : hdrbuf(nTypeIn, nVersionIn), hdr(pchMessageStartIn), vRecv(nTypeIn, nVersionIn) {
535  hdrbuf.resize(24);
536  in_data = false;
537  nHdrPos = 0;
538  nDataPos = 0;
539  nTime = 0;
540  }
541 
542  bool complete() const
543  {
544  if (!in_data)
545  return false;
546  return (hdr.nMessageSize == nDataPos);
547  }
548 
549  const uint256& GetMessageHash() const;
550 
551  void SetVersion(int nVersionIn)
552  {
553  hdrbuf.SetVersion(nVersionIn);
554  vRecv.SetVersion(nVersionIn);
555  }
556 
557  int readHeader(const char *pch, unsigned int nBytes);
558  int readData(const char *pch, unsigned int nBytes);
559 };
560 
561 
563 class CNode
564 {
565  friend class CConnman;
566 public:
567  // socket
568  std::atomic<ServiceFlags> nServices;
571  size_t nSendSize; // total size of all vSendMsg entries
572  size_t nSendOffset; // offset inside the first vSendMsg already sent
573  uint64_t nSendBytes;
574  std::deque<std::vector<unsigned char>> vSendMsg;
578 
580  std::list<CNetMessage> vProcessMsg;
582 
584 
585  std::deque<CInv> vRecvGetData;
586  uint64_t nRecvBytes;
587  std::atomic<int> nRecvVersion;
588 
589  std::atomic<int64_t> nLastSend;
590  std::atomic<int64_t> nLastRecv;
591  const int64_t nTimeConnected;
592  std::atomic<int64_t> nTimeOffset;
593  const CAddress addr;
594  std::atomic<int> nVersion;
595  // strSubVer is whatever byte array we read from the wire. However, this field is intended
596  // to be printed out, displayed to humans in various forms and so on. So we sanitize it and
597  // store the sanitized version in cleanSubVer. The original should be used when dealing with
598  // the network or wire types and the cleaned string used when displayed or logged.
599  std::string strSubVer, cleanSubVer;
600  CCriticalSection cs_SubVer; // used for both cleanSubVer and strSubVer
601  bool fWhitelisted; // This peer can bypass DoS banning.
602  bool fFeeler; // If true this node is being used as a short lived feeler.
603  bool fOneShot;
604  bool fAddnode;
605  bool fClient;
606  const bool fInbound;
607  std::atomic_bool fSuccessfullyConnected;
608  std::atomic_bool fDisconnect;
609  // We use fRelayTxes for two purposes -
610  // a) it allows us to not relay tx invs before receiving the peer's version message
611  // b) the peer may tell us in its version message that we should not relay tx invs
612  // unless it loads a bloom filter.
613  bool fRelayTxes; //protected by cs_filter
614  bool fSentAddr;
618  std::atomic<int> nRefCount;
619  const NodeId id;
620 
621  const uint64_t nKeyedNetGroup;
622  std::atomic_bool fPauseRecv;
623  std::atomic_bool fPauseSend;
624 protected:
625 
628 
629 public:
631  std::atomic<int> nStartingHeight;
632 
633  // flood relay
634  std::vector<CAddress> vAddrToSend;
636  bool fGetAddr;
637  std::set<uint256> setKnown;
638  int64_t nNextAddrSend;
640 
641  // inventory based relay
643  // Set of transaction ids we still have to announce.
644  // They are sorted by the mempool before relay, so the order is not important.
645  std::set<uint256> setInventoryTxToSend;
646  // List of block ids we still have announce.
647  // There is no final sorting before sending, as they are always sent immediately
648  // and in the order requested.
649  std::vector<uint256> vInventoryBlockToSend;
651  std::set<uint256> setAskFor;
652  std::multimap<int64_t, CInv> mapAskFor;
653  int64_t nNextInvSend;
654  // Used for headers announcements - unfiltered blocks to relay
655  // Also protected by cs_inventory
656  std::vector<uint256> vBlockHashesToAnnounce;
657  // Used for BIP35 mempool sending, also protected by cs_inventory
659 
660  // Last time a "MEMPOOL" request was serviced.
661  std::atomic<int64_t> timeLastMempoolReq;
662 
663  // Block and TXN accept times
664  std::atomic<int64_t> nLastBlockTime;
665  std::atomic<int64_t> nLastTXTime;
666 
667  // Ping time measurement:
668  // The pong reply we're expecting, or 0 if no pong expected.
669  std::atomic<uint64_t> nPingNonceSent;
670  // Time (in usec) the last ping was sent, or 0 if no ping was ever sent.
671  std::atomic<int64_t> nPingUsecStart;
672  // Last measured round-trip time.
673  std::atomic<int64_t> nPingUsecTime;
674  // Best measured round-trip time.
675  std::atomic<int64_t> nMinPingUsecTime;
676  // Whether a ping is requested.
677  std::atomic<bool> fPingQueued;
678  // Minimum fee rate with which to filter inv's to this node
683 
684  // Alert relay
685  std::vector<CAlert> vAlertToSend;
686 
687  CNode(NodeId id, ServiceFlags nLocalServicesIn, int nMyStartingHeightIn, SOCKET hSocketIn, const CAddress &addrIn, uint64_t nKeyedNetGroupIn, uint64_t nLocalHostNonceIn, const std::string &addrNameIn = "", bool fInboundIn = false);
688  ~CNode();
689 
690 private:
691  CNode(const CNode&);
692  void operator=(const CNode&);
693 
694 
695  const uint64_t nLocalHostNonce;
696  // Services offered to this peer
698  const int nMyStartingHeight;
700  std::list<CNetMessage> vRecvMsg; // Used only by SocketHandler thread
701 
703  std::string addrName;
704 
707 public:
708 
709  NodeId GetId() const {
710  return id;
711  }
712 
713  uint64_t GetLocalNonce() const {
714  return nLocalHostNonce;
715  }
716 
717  int GetMyStartingHeight() const {
718  return nMyStartingHeight;
719  }
720 
722  {
723  assert(nRefCount >= 0);
724  return nRefCount;
725  }
726 
727  bool ReceiveMsgBytes(const char *pch, unsigned int nBytes, bool& complete);
728 
729  void SetRecvVersion(int nVersionIn)
730  {
731  nRecvVersion = nVersionIn;
732  }
734  {
735  return nRecvVersion;
736  }
737  void SetSendVersion(int nVersionIn);
738  int GetSendVersion() const;
739 
740  CService GetAddrLocal() const;
742  void SetAddrLocal(const CService& addrLocalIn);
743 
745  {
746  nRefCount++;
747  return this;
748  }
749 
750  void Release()
751  {
752  nRefCount--;
753  }
754 
755 
756 
757  void AddAddressKnown(const CAddress& _addr)
758  {
759  addrKnown.insert(_addr.GetKey());
760  }
761 
762  void PushAddress(const CAddress& _addr, FastRandomContext &insecure_rand)
763  {
764  // Known checking here is only to save space from duplicates.
765  // SendMessages will filter it again for knowns that were added
766  // after addresses were pushed.
767  if (_addr.IsValid() && !addrKnown.contains(_addr.GetKey())) {
768  if (vAddrToSend.size() >= MAX_ADDR_TO_SEND) {
769  vAddrToSend[insecure_rand.rand32() % vAddrToSend.size()] = _addr;
770  } else {
771  vAddrToSend.push_back(_addr);
772  }
773  }
774  }
775 
776  void PushAlert(const CAlert& _alert)
777  {
778  // don't relay to nodes which haven't sent their version message
779  if (_alert.IsInEffect() && nVersion != 0) {
780  vAlertToSend.push_back(_alert);
781  }
782  }
783 
784 
785  void AddInventoryKnown(const CInv& inv)
786  {
787  {
790  }
791  }
792 
793  void PushInventory(const CInv& inv)
794  {
796  if (inv.type == MSG_TX) {
797  if (!filterInventoryKnown.contains(inv.hash)) {
798  setInventoryTxToSend.insert(inv.hash);
799  }
800  } else if (inv.type == MSG_BLOCK) {
801  vInventoryBlockToSend.push_back(inv.hash);
802  }
803  }
804 
805  void PushAlertHash(const uint256 &hash)
806  {
808  vBlockHashesToAnnounce.push_back(hash);
809  }
810 
811  void PushBlockHash(const uint256 &hash)
812  {
814  vBlockHashesToAnnounce.push_back(hash);
815  }
816 
817  void AskFor(const CInv& inv);
818 
819  void CloseSocketDisconnect();
820 
821  void copyStats(CNodeStats &stats);
822 
824  {
825  return nLocalServices;
826  }
827 
828  std::string GetAddrName() const;
830  void MaybeSetAddrName(const std::string& addrNameIn);
831 };
832 
833 
834 
835 
836 
838 int64_t PoissonNextSend(int64_t nNow, int average_interval_seconds);
839 
840 #endif // BITCOIN_NET_H
BanReason
Definition: addrdb.h:20
std::map< CSubNet, CBanEntry > banmap_t
Definition: addrdb.h:77
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:15
Stochastical (IP) address manager.
Definition: addrman.h:178
A CService with information about it as peer.
Definition: protocol.h:289
An alert is a combination of a serialized CUnsignedAlert and a signature.
Definition: alert.h:77
bool IsInEffect() const
Definition: alert.cpp:103
BloomFilter is a probabilistic filter which SPV clients provide so that we can filter the transaction...
Definition: bloom.h:45
Signals for UI communication.
Definition: ui_interface.h:30
Definition: net.h:125
std::condition_variable condMsgProc
Definition: net.h:396
void AddWhitelistedRange(const CSubNet &subnet)
Definition: net.cpp:594
uint64_t nMaxOutboundLimit
Definition: net.h:348
void SweepBanned()
clean unused entries (if bantime has expired)
Definition: net.cpp:551
std::thread threadMessageHandler
Definition: net.h:406
void ThreadOpenAddedConnections()
Definition: net.cpp:1893
int GetBestHeight() const
Definition: net.cpp:2639
void ProcessOneShot()
Definition: net.cpp:1650
bool ForNode(NodeId id, std::function< bool(CNode *pnode)> func)
Definition: net.cpp:2802
size_t SocketSendData(CNode *pnode) const
Definition: net.cpp:828
CCriticalSection cs_vNodes
Definition: net.h:372
void DeleteNode(CNode *pnode)
Definition: net.cpp:2404
bool setBannedIsDirty
Definition: net.h:363
bool AttemptToEvictConnection()
Try to find a connection to evict when the node is full.
Definition: net.cpp:933
bool GetNetworkActive() const
Definition: net.h:156
std::mutex mutexMsgProc
Definition: net.h:397
void ForEachNodeThen(Callable &&pre, CallableAfter &&post) const
Definition: net.h:197
ServiceFlags nLocalServices
Services this instance offers.
Definition: net.h:376
size_t GetNodeCount(NumConnections num)
Definition: net.cpp:2474
void Stop()
Definition: net.cpp:2361
CAddrMan addrman
Definition: net.h:365
std::atomic< bool > flagInterruptMsgProc
Definition: net.h:398
unsigned int GetReceiveFloodSize() const
Definition: net.cpp:2644
std::list< CNode * > vNodesDisconnected
Definition: net.h:371
uint64_t GetTotalBytesRecv()
Definition: net.cpp:2617
void SetBestHeight(int height)
Definition: net.cpp:2634
CCriticalSection cs_totalBytesRecv
Definition: net.h:340
void ForEachNodeThen(Callable &&pre, CallableAfter &&post)
Definition: net.h:186
void AddNewAddress(const CAddress &addr, const CAddress &addrFrom, int64_t nTimePenalty=0)
Definition: net.cpp:2435
NodeId GetNewNodeId()
Definition: net.cpp:2212
CSemaphore * semAddnode
Definition: net.h:382
CThreadInterrupt interruptNet
Definition: net.h:400
uint64_t GetMaxOutboundTimeframe()
Definition: net.cpp:2556
std::atomic< NodeId > nLastNodeId
Definition: net.h:373
void SetMaxOutboundTimeframe(uint64_t timeframe)
set the timeframe for the max outbound target
Definition: net.cpp:2576
void SetServices(const CService &addr, ServiceFlags nServices)
Definition: net.cpp:2425
uint64_t GetOutboundTargetBytesLeft()
response the bytes left in the current max outbound cycle
Definition: net.cpp:2608
size_t GetAddressCount() const
Definition: net.cpp:2420
void AddNewAddresses(const std::vector< CAddress > &vAddr, const CAddress &addrFrom, int64_t nTimePenalty=0)
Definition: net.cpp:2440
uint64_t nTotalBytesSent
Definition: net.h:343
void RecordBytesSent(uint64_t bytes)
Definition: net.cpp:2527
bool OpenNetworkConnection(const CAddress &addrConnect, bool fCountFailure, CSemaphoreGrant *grantOutbound=NULL, const char *strDest=NULL, bool fOneShot=false, bool fFeeler=false, bool fAddnode=false)
Definition: net.cpp:1929
std::vector< CAddress > GetAddresses()
Definition: net.cpp:2445
void Interrupt()
Definition: net.cpp:2337
std::thread threadDNSAddressSeed
Definition: net.h:402
bool Unban(const CNetAddr &ip)
Definition: net.cpp:518
CCriticalSection cs_totalBytesSent
Definition: net.h:341
CSemaphore * semOutbound
Definition: net.h:381
std::deque< std::string > vOneShots
Definition: net.h:366
const uint64_t nSeed1
Definition: net.h:391
void SetBannedSetDirty(bool dirty=true)
set the "dirty" flag for the banlist
Definition: net.cpp:578
ServiceFlags GetLocalServices() const
Definition: net.cpp:2629
bool DisconnectNode(const std::string &node)
Definition: net.cpp:2500
uint64_t nMaxOutboundTimeframe
Definition: net.h:349
ServiceFlags nRelevantServices
Services this instance cares about.
Definition: net.h:379
std::vector< ListenSocket > vhListenSocket
Definition: net.h:359
void ClearBanned()
Definition: net.cpp:436
void DumpBanlist()
Definition: net.cpp:405
CClientUIInterface * clientInterface
Definition: net.h:388
CSipHasher GetDeterministicRandomizer(uint64_t id) const
Get a unique deterministic randomizer.
Definition: net.cpp:2819
void GetBanned(banmap_t &banmap)
Definition: net.cpp:536
CCriticalSection cs_setBanned
Definition: net.h:362
void ThreadSocketHandler()
Definition: net.cpp:1109
std::thread threadOpenConnections
Definition: net.h:405
void ForEachNode(Callable &&func) const
Definition: net.h:176
NumConnections
Definition: net.h:128
@ CONNECTIONS_IN
Definition: net.h:130
@ CONNECTIONS_NONE
Definition: net.h:129
@ CONNECTIONS_ALL
Definition: net.h:132
@ CONNECTIONS_OUT
Definition: net.h:131
uint64_t nTotalBytesRecv
Definition: net.h:342
bool fMsgProcWake
flag for waking the message processor.
Definition: net.h:394
CNode * FindNode(const CNetAddr &ip)
Definition: net.cpp:290
bool Start(CScheduler &scheduler, std::string &strNodeError, Options options)
Definition: net.cpp:2217
unsigned int GetSendBufferSize() const
Definition: net.cpp:2645
void MarkAddressGood(const CAddress &addr)
Definition: net.cpp:2430
const uint64_t nSeed0
SipHasher seeds for deterministic randomness.
Definition: net.h:391
unsigned int nReceiveFloodSize
Definition: net.h:357
uint64_t nMaxOutboundTotalBytesSentInCycle
Definition: net.h:346
uint64_t nMaxOutboundCycleStartTime
Definition: net.h:347
static bool NodeFullyConnected(const CNode *pnode)
Definition: net.cpp:2760
int nMaxConnections
Definition: net.h:383
void SetMaxOutboundTarget(uint64_t limit)
set the max outbound target in bytes
Definition: net.cpp:2544
void WakeMessageHandler()
Definition: net.cpp:1408
void SetNetworkActive(bool active)
Definition: net.cpp:2173
uint64_t GetMaxOutboundTarget()
Definition: net.cpp:2550
bool IsBanned(CNetAddr ip)
Definition: net.cpp:448
bool OutboundTargetReached(bool historicalBlockServingLimit)
check if the outbound target is reached
Definition: net.cpp:2588
void ThreadDNSAddressSeed()
Definition: net.cpp:1556
std::vector< CSubNet > vWhitelistedRange
Definition: net.h:353
void ThreadMessageHandler()
Definition: net.cpp:1970
uint64_t CalculateKeyedNetGroup(const CAddress &ad) const
Definition: net.cpp:2824
bool fAddressesInitialized
Definition: net.h:364
uint64_t GetTotalBytesSent()
Definition: net.cpp:2623
uint64_t GetMaxOutboundTimeLeftInCycle()
response the time in second left in the current max outbound cycle
Definition: net.cpp:2562
~CConnman()
Definition: net.cpp:2414
std::thread threadOpenAddedConnections
Definition: net.h:404
int nMaxOutbound
Definition: net.h:384
void ThreadOpenConnections()
Definition: net.cpp:1668
void Ban(const CNetAddr &netAddr, const BanReason &reason, int64_t bantimeoffset=0, bool sinceUnixEpoch=false)
Definition: net.cpp:481
bool BannedSetIsDirty()
check is the banlist has unwritten changes
Definition: net.cpp:572
CNode * ConnectNode(CAddress addrConnect, const char *pszDest, bool fCountFailure)
Definition: net.cpp:338
std::atomic< int > nBestHeight
Definition: net.h:387
bool CheckIncomingNonce(uint64_t nonce)
Definition: net.cpp:328
banmap_t setBanned
Definition: net.h:361
int nMaxAddnode
Definition: net.h:385
bool BindListenPort(const CService &bindAddr, std::string &strError, bool fWhitelisted=false)
Definition: net.cpp:2024
void RecordBytesRecv(uint64_t bytes)
Definition: net.cpp:2521
void DumpData()
Definition: net.cpp:1644
std::vector< AddedNodeInfo > GetAddedNodeInfo()
Definition: net.cpp:1840
void GetNodeStats(std::vector< CNodeStats > &vstats)
Definition: net.cpp:2488
std::vector< std::string > vAddedNodes
Definition: net.h:368
void PushMessage(CNode *pnode, CSerializedNetMsg &&msg)
Definition: net.cpp:2765
std::vector< CNode * > vNodes
Definition: net.h:370
CCriticalSection cs_vWhitelistedRange
Definition: net.h:354
unsigned int nSendBufferMaxSize
Definition: net.h:356
void SetBanned(const banmap_t &banmap)
Definition: net.cpp:544
std::atomic< bool > fNetworkActive
Definition: net.h:360
void ForEachNode(Callable &&func)
Definition: net.h:166
CConnman(uint64_t seed0, uint64_t seed1)
Definition: net.cpp:2194
CCriticalSection cs_vOneShots
Definition: net.h:367
void DumpAddresses()
Definition: net.cpp:1633
CCriticalSection cs_vAddedNodes
Definition: net.h:369
bool AddNode(const std::string &node)
Definition: net.cpp:2450
int nMaxFeeler
Definition: net.h:386
std::thread threadSocketHandler
Definition: net.h:403
void AddressCurrentlyConnected(const CService &addr)
bool RemoveAddedNode(const std::string &node)
Definition: net.cpp:2462
void AddOneShot(const std::string &strDest)
Definition: net.cpp:83
bool IsWhitelistedRange(const CNetAddr &addr)
Definition: net.cpp:585
void AcceptConnection(const ListenSocket &hListenSocket)
Definition: net.cpp:1026
Wrapped boost mutex: supports recursive locking, but no waiting TODO: We should move away from using ...
Definition: sync.h:93
Double ended buffer combining vector and stream-like interfaces.
Definition: streams.h:147
void SetVersion(int n)
Definition: streams.h:339
void resize(size_type n, value_type c=0)
Definition: streams.h:239
A hasher class for Bitcoin's 256-bit hash (double SHA-256).
Definition: hash.h:21
inv message data
Definition: protocol.h:346
int type
Definition: protocol.h:367
uint256 hash
Definition: protocol.h:368
Message header.
Definition: protocol.h:28
unsigned char MessageStartChars[MESSAGE_START_SIZE]
Definition: protocol.h:40
uint32_t nMessageSize
Definition: protocol.h:61
IP address (IPv6, or IPv4 using mapped IPv6 range (::FFFF:0:0/96))
Definition: netaddress.h:31
bool IsValid() const
Definition: netaddress.cpp:188
CHash256 hasher
Definition: net.h:520
CNetMessage(const CMessageHeader::MessageStartChars &pchMessageStartIn, int nTypeIn, int nVersionIn)
Definition: net.h:534
CDataStream vRecv
Definition: net.h:529
unsigned int nHdrPos
Definition: net.h:527
int readHeader(const char *pch, unsigned int nBytes)
Definition: net.cpp:763
unsigned int nDataPos
Definition: net.h:530
const uint256 & GetMessageHash() const
Definition: net.cpp:811
void SetVersion(int nVersionIn)
Definition: net.h:551
CDataStream hdrbuf
Definition: net.h:525
bool in_data
Definition: net.h:523
uint256 data_hash
Definition: net.h:521
int64_t nTime
Definition: net.h:532
int readData(const char *pch, unsigned int nBytes)
Definition: net.cpp:794
bool complete() const
Definition: net.h:542
CMessageHeader hdr
Definition: net.h:526
Information about a peer.
Definition: net.h:564
std::atomic< int64_t > nLastSend
Definition: net.h:589
CCriticalSection cs_sendProcessing
Definition: net.h:583
bool fAddnode
Definition: net.h:604
std::string cleanSubVer
Definition: net.h:599
size_t nSendOffset
Definition: net.h:572
CRollingBloomFilter filterInventoryKnown
Definition: net.h:642
std::atomic< int > nVersion
Definition: net.h:594
void SetSendVersion(int nVersionIn)
Definition: net.cpp:736
std::vector< uint256 > vInventoryBlockToSend
Definition: net.h:649
std::deque< std::vector< unsigned char > > vSendMsg
Definition: net.h:574
CCriticalSection cs_vRecv
Definition: net.h:577
std::atomic_bool fPauseRecv
Definition: net.h:622
NodeId GetId() const
Definition: net.h:709
uint256 hashContinue
Definition: net.h:630
std::atomic< int64_t > nTimeOffset
Definition: net.h:592
CService addrLocal
Definition: net.h:705
CCriticalSection cs_inventory
Definition: net.h:650
void PushAddress(const CAddress &_addr, FastRandomContext &insecure_rand)
Definition: net.h:762
void PushAlertHash(const uint256 &hash)
Definition: net.h:805
std::atomic< bool > fPingQueued
Definition: net.h:677
int GetSendVersion() const
Definition: net.cpp:750
bool fFeeler
Definition: net.h:602
bool fOneShot
Definition: net.h:603
CBloomFilter * pfilter
Definition: net.h:617
CCriticalSection cs_feeFilter
Definition: net.h:680
std::list< CNetMessage > vRecvMsg
Definition: net.h:700
mapMsgCmdSize mapRecvBytesPerMsgCmd
Definition: net.h:627
size_t nProcessQueueSize
Definition: net.h:581
std::string addrName
Definition: net.h:703
void SetAddrLocal(const CService &addrLocalIn)
May not be called more than once.
Definition: net.cpp:617
std::vector< CAlert > vAlertToSend
Definition: net.h:685
uint64_t nSendBytes
Definition: net.h:573
std::atomic_bool fSuccessfullyConnected
Definition: net.h:607
ServiceFlags nServicesExpected
Definition: net.h:569
uint64_t GetLocalNonce() const
Definition: net.h:713
size_t nSendSize
Definition: net.h:571
std::atomic< ServiceFlags > nServices
Definition: net.h:568
bool fGetAddr
Definition: net.h:636
CRollingBloomFilter addrKnown
Definition: net.h:635
CCriticalSection cs_hSocket
Definition: net.h:576
const CAddress addr
Definition: net.h:593
CSemaphoreGrant grantOutbound
Definition: net.h:615
const int64_t nTimeConnected
Definition: net.h:591
std::string GetAddrName() const
Definition: net.cpp:600
mapMsgCmdSize mapSendBytesPerMsgCmd
Definition: net.h:626
const uint64_t nKeyedNetGroup
Definition: net.h:621
std::atomic< int > nRefCount
Definition: net.h:618
int GetMyStartingHeight() const
Definition: net.h:717
void CloseSocketDisconnect()
Definition: net.cpp:425
CCriticalSection cs_filter
Definition: net.h:616
CCriticalSection cs_addrName
Definition: net.h:702
std::atomic< int > nStartingHeight
Definition: net.h:631
void PushAlert(const CAlert &_alert)
Definition: net.h:776
bool fClient
Definition: net.h:605
int GetRefCount()
Definition: net.h:721
std::atomic_bool fPauseSend
Definition: net.h:623
std::multimap< int64_t, CInv > mapAskFor
Definition: net.h:652
CAmount minFeeFilter
Definition: net.h:679
CCriticalSection cs_vSend
Definition: net.h:575
SOCKET hSocket
Definition: net.h:570
void PushInventory(const CInv &inv)
Definition: net.h:793
const ServiceFlags nLocalServices
Definition: net.h:697
bool ReceiveMsgBytes(const char *pch, unsigned int nBytes, bool &complete)
Definition: net.cpp:684
CCriticalSection cs_vProcessMsg
Definition: net.h:579
CCriticalSection cs_addrLocal
Definition: net.h:706
int GetRecvVersion()
Definition: net.h:733
int64_t nextSendTimeFeeFilter
Definition: net.h:682
void MaybeSetAddrName(const std::string &addrNameIn)
Sets the addrName only if it was not previously set.
Definition: net.cpp:605
int64_t nNextInvSend
Definition: net.h:653
uint64_t nRecvBytes
Definition: net.h:586
void operator=(const CNode &)
std::atomic< int64_t > timeLastMempoolReq
Definition: net.h:661
void AddAddressKnown(const CAddress &_addr)
Definition: net.h:757
std::atomic< int64_t > nLastRecv
Definition: net.h:590
void SetRecvVersion(int nVersionIn)
Definition: net.h:729
std::deque< CInv > vRecvGetData
Definition: net.h:585
std::atomic< int64_t > nLastTXTime
Definition: net.h:665
std::atomic< int64_t > nMinPingUsecTime
Definition: net.h:675
std::atomic< uint64_t > nPingNonceSent
Definition: net.h:669
std::vector< CAddress > vAddrToSend
Definition: net.h:634
std::set< uint256 > setAskFor
Definition: net.h:651
CAmount lastSentFeeFilter
Definition: net.h:681
const int nMyStartingHeight
Definition: net.h:698
const uint64_t nLocalHostNonce
Definition: net.h:695
std::atomic< int64_t > nPingUsecStart
Definition: net.h:671
void PushBlockHash(const uint256 &hash)
Definition: net.h:811
bool fSentAddr
Definition: net.h:614
void copyStats(CNodeStats &stats)
Definition: net.cpp:628
ServiceFlags GetLocalServices() const
Definition: net.h:823
CNode(NodeId id, ServiceFlags nLocalServicesIn, int nMyStartingHeightIn, SOCKET hSocketIn, const CAddress &addrIn, uint64_t nKeyedNetGroupIn, uint64_t nLocalHostNonceIn, const std::string &addrNameIn="", bool fInboundIn=false)
Definition: net.cpp:2647
std::set< uint256 > setKnown
Definition: net.h:637
bool fRelayTxes
Definition: net.h:613
std::atomic< int64_t > nPingUsecTime
Definition: net.h:673
const NodeId id
Definition: net.h:619
CNode(const CNode &)
int nSendVersion
Definition: net.h:699
void AddInventoryKnown(const CInv &inv)
Definition: net.h:785
bool fSendMempool
Definition: net.h:658
~CNode()
Definition: net.cpp:2718
std::list< CNetMessage > vProcessMsg
Definition: net.h:580
CCriticalSection cs_SubVer
Definition: net.h:600
std::atomic< int64_t > nLastBlockTime
Definition: net.h:664
bool fWhitelisted
Definition: net.h:601
std::vector< uint256 > vBlockHashesToAnnounce
Definition: net.h:656
const bool fInbound
Definition: net.h:606
std::atomic_bool fDisconnect
Definition: net.h:608
void AskFor(const CInv &inv)
Definition: net.cpp:2726
CService GetAddrLocal() const
Definition: net.cpp:612
std::set< uint256 > setInventoryTxToSend
Definition: net.h:645
std::atomic< int > nRecvVersion
Definition: net.h:587
int64_t nNextLocalAddrSend
Definition: net.h:639
void Release()
Definition: net.h:750
std::string strSubVer
Definition: net.h:599
CNode * AddRef()
Definition: net.h:744
int64_t nNextAddrSend
Definition: net.h:638
std::string addrLocal
Definition: net.h:511
double dPingWait
Definition: net.h:509
uint64_t nRecvBytes
Definition: net.h:505
mapMsgCmdSize mapSendBytesPerMsgCmd
Definition: net.h:504
bool fRelayTxes
Definition: net.h:492
std::string addrName
Definition: net.h:497
bool fInbound
Definition: net.h:500
bool fWhitelisted
Definition: net.h:507
uint64_t nSendBytes
Definition: net.h:503
int64_t nTimeConnected
Definition: net.h:495
double dPingTime
Definition: net.h:508
CAddress addr
Definition: net.h:512
bool fAddnode
Definition: net.h:501
int64_t nLastRecv
Definition: net.h:494
double dMinPing
Definition: net.h:510
ServiceFlags nServices
Definition: net.h:491
int nStartingHeight
Definition: net.h:502
int64_t nTimeOffset
Definition: net.h:496
mapMsgCmdSize mapRecvBytesPerMsgCmd
Definition: net.h:506
int nVersion
Definition: net.h:498
NodeId nodeid
Definition: net.h:490
std::string cleanSubVer
Definition: net.h:499
int64_t nLastSend
Definition: net.h:493
RollingBloomFilter is a probabilistic "keep track of most recently inserted" set.
Definition: bloom.h:120
void insert(const std::vector< unsigned char > &vKey)
Definition: bloom.cpp:249
bool contains(const std::vector< unsigned char > &vKey) const
Definition: bloom.cpp:285
RAII-style semaphore lock.
Definition: sync.h:233
A combination of a network address (CNetAddr) and a (TCP) port.
Definition: netaddress.h:134
std::vector< unsigned char > GetKey() const
Definition: netaddress.cpp:544
SipHash-2-4.
Definition: hash.h:178
The basic transaction that is broadcasted on the network and contained in blocks.
Definition: transaction.h:308
Fast randomness source.
Definition: random.h:35
uint32_t rand32()
Definition: random.h:39
STL-like map container that only keeps the N elements with the highest value.
Definition: limitedmap.h:14
256-bit opaque blob.
Definition: uint256.h:123
u_int SOCKET
Definition: compat.h:53
CAddress GetLocalAddress(const CNetAddr *paddrPeer, ServiceFlags nLocalServices)
Definition: net.cpp:144
bool RemoveLocal(const CService &addr)
Definition: net.cpp:227
bool IsPeerAddrLocalGood(CNode *pnode)
Definition: net.cpp:165
std::map< CNetAddr, LocalServiceInfo > mapLocalHost
Definition: net.cpp:73
void AdvertiseLocal(CNode *pnode)
Definition: net.cpp:173
std::unique_ptr< CConnman > g_connman
Definition: init.cpp:75
bool IsLocal(const CService &addr)
check whether a given address is potentially local
Definition: net.cpp:269
bool AddLocal(const CService &addr, int nScore=LOCAL_NONE)
Definition: net.cpp:196
bool fDiscover
Definition: net.cpp:69
CNodeSignals & GetNodeSignals()
Definition: net.cpp:81
bool fListen
Definition: net.cpp:70
CCriticalSection cs_mapLocalHost
Definition: net.cpp:72
int64_t PoissonNextSend(int64_t nNow, int average_interval_seconds)
Return a timestamp in the future (in microseconds) for exponentially distributed events.
Definition: net.cpp:2815
std::string strSubVersion
Subversion as sent to the P2P network in version messages.
Definition: net.cpp:75
limitedmap< uint256, int64_t > mapAlreadyAskedFor
bool fRelayTxes
Definition: net.cpp:71
void Discover(boost::thread_group &threadGroup)
Definition: net.cpp:2122
bool BindListenPort(const CService &bindAddr, std::string &strError, bool fWhitelisted=false)
bool IsLimited(enum Network net)
Definition: net.cpp:244
void MapPort(bool fUseUPnP)
Definition: net.cpp:1532
int64_t NodeId
Definition: net.h:96
std::map< std::string, uint64_t > mapMsgCmdSize
Definition: net.h:485
bool GetLocal(CService &addr, const CNetAddr *paddrPeer=NULL)
Definition: net.cpp:95
@ LOCAL_NONE
Definition: net.h:444
@ LOCAL_MANUAL
Definition: net.h:448
@ LOCAL_MAX
Definition: net.h:450
@ LOCAL_UPNP
Definition: net.h:447
@ LOCAL_BIND
Definition: net.h:446
@ LOCAL_IF
Definition: net.h:445
void SetLimited(enum Network net, bool fLimited=true)
Make a particular network entirely off-limits (no automatic connects to it)
Definition: net.cpp:236
unsigned short GetListenPort()
Definition: net.cpp:89
bool IsReachable(enum Network net)
check whether a given network is one we can probably connect to
Definition: net.cpp:276
bool SeenLocal(const CService &addr)
vote for a local address
Definition: net.cpp:256
Network
Definition: netaddress.h:20
@ MSG_TX
Definition: protocol.h:334
@ MSG_BLOCK
Definition: protocol.h:335
ServiceFlags
nServices flags
Definition: protocol.h:256
@ NODE_NONE
Definition: protocol.h:258
@ NODE_NETWORK
Definition: protocol.h:262
bool fInbound
Definition: net.h:103
CService resolvedAddress
Definition: net.h:101
bool fConnected
Definition: net.h:102
std::string strAddedNode
Definition: net.h:100
ListenSocket(SOCKET socket_, bool whitelisted_)
Definition: net.h:295
unsigned int nReceiveFloodSize
Definition: net.h:146
uint64_t nMaxOutboundLimit
Definition: net.h:148
CClientUIInterface * uiInterface
Definition: net.h:144
int nMaxOutbound
Definition: net.h:140
int nBestHeight
Definition: net.h:143
int nMaxFeeler
Definition: net.h:142
uint64_t nMaxOutboundTimeframe
Definition: net.h:147
int nMaxConnections
Definition: net.h:139
ServiceFlags nLocalServices
Definition: net.h:137
ServiceFlags nRelevantServices
Definition: net.h:138
unsigned int nSendBufferMaxSize
Definition: net.h:145
int nMaxAddnode
Definition: net.h:141
boost::signals2::signal< void(CNode *, CConnman &)> InitializeNode
Definition: net.h:434
boost::signals2::signal< bool(CNode *, CConnman &, std::atomic< bool > &), CombinerAll > ProcessMessages
Definition: net.h:432
boost::signals2::signal< bool(CNode *, CConnman &, std::atomic< bool > &), CombinerAll > SendMessages
Definition: net.h:433
boost::signals2::signal< void(NodeId, bool &)> FinalizeNode
Definition: net.h:435
CSerializedNetMsg(const CSerializedNetMsg &msg)=delete
std::string command
Definition: net.h:120
CSerializedNetMsg & operator=(const CSerializedNetMsg &)=delete
CSerializedNetMsg()=default
CSerializedNetMsg(CSerializedNetMsg &&)=default
CSerializedNetMsg & operator=(CSerializedNetMsg &&)=default
std::vector< unsigned char > data
Definition: net.h:119
bool operator()(I first, I last) const
Definition: net.h:419
bool result_type
Definition: net.h:416
int nScore
Definition: net.h:479
#define LOCK(cs)
Definition: sync.h:177