]> Git Repo - VerusCoin.git/blob - src/net.h
Merge pull request #4504
[VerusCoin.git] / src / net.h
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2014 The Bitcoin developers
3 // Distributed under the MIT/X11 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 "bloom.h"
10 #include "compat.h"
11 #include "hash.h"
12 #include "limitedmap.h"
13 #include "mruset.h"
14 #include "netbase.h"
15 #include "protocol.h"
16 #include "random.h"
17 #include "sync.h"
18 #include "uint256.h"
19 #include "util.h"
20
21 #include <deque>
22 #include <stdint.h>
23
24 #ifndef WIN32
25 #include <arpa/inet.h>
26 #endif
27
28 #include <boost/foreach.hpp>
29 #include <boost/signals2/signal.hpp>
30
31 class CAddrMan;
32 class CBlockIndex;
33 class CNode;
34
35 namespace boost {
36     class thread_group;
37 } // namespace boost
38
39 /** Time between pings automatically sent out for latency probing and keepalive (in seconds). */
40 static const int PING_INTERVAL = 2 * 60;
41 /** Time after which to disconnect, after waiting for a ping response (or inactivity). */
42 static const int TIMEOUT_INTERVAL = 20 * 60;
43 /** The maximum number of entries in an 'inv' protocol message */
44 static const unsigned int MAX_INV_SZ = 50000;
45 /** -listen default */
46 static const bool DEFAULT_LISTEN = true;
47 /** -upnp default */
48 #ifdef USE_UPNP
49 static const bool DEFAULT_UPNP = USE_UPNP;
50 #else
51 static const bool DEFAULT_UPNP = false;
52 #endif
53
54 inline unsigned int ReceiveFloodSize() { return 1000*GetArg("-maxreceivebuffer", 5*1000); }
55 inline unsigned int SendBufferSize() { return 1000*GetArg("-maxsendbuffer", 1*1000); }
56
57 void AddOneShot(std::string strDest);
58 bool RecvLine(SOCKET hSocket, std::string& strLine);
59 bool GetMyExternalIP(CNetAddr& ipRet);
60 void AddressCurrentlyConnected(const CService& addr);
61 CNode* FindNode(const CNetAddr& ip);
62 CNode* FindNode(const CService& ip);
63 CNode* ConnectNode(CAddress addrConnect, const char *pszDest = NULL);
64 bool OpenNetworkConnection(const CAddress& addrConnect, CSemaphoreGrant *grantOutbound = NULL, const char *strDest = NULL, bool fOneShot = false);
65 void MapPort(bool fUseUPnP);
66 unsigned short GetListenPort();
67 bool BindListenPort(const CService &bindAddr, std::string& strError, bool fWhitelisted = false);
68 void StartNode(boost::thread_group& threadGroup);
69 bool StopNode();
70 void SocketSendData(CNode *pnode);
71
72 typedef int NodeId;
73
74 // Signals for message handling
75 struct CNodeSignals
76 {
77     boost::signals2::signal<int ()> GetHeight;
78     boost::signals2::signal<bool (CNode*)> ProcessMessages;
79     boost::signals2::signal<bool (CNode*, bool)> SendMessages;
80     boost::signals2::signal<void (NodeId, const CNode*)> InitializeNode;
81     boost::signals2::signal<void (NodeId)> FinalizeNode;
82 };
83
84
85 CNodeSignals& GetNodeSignals();
86
87
88 enum
89 {
90     LOCAL_NONE,   // unknown
91     LOCAL_IF,     // address a local interface listens on
92     LOCAL_BIND,   // address explicit bound to
93     LOCAL_UPNP,   // address reported by UPnP
94     LOCAL_HTTP,   // address reported by whatismyip.com and similar
95     LOCAL_MANUAL, // address explicitly specified (-externalip=)
96
97     LOCAL_MAX
98 };
99
100 void SetLimited(enum Network net, bool fLimited = true);
101 bool IsLimited(enum Network net);
102 bool IsLimited(const CNetAddr& addr);
103 bool AddLocal(const CService& addr, int nScore = LOCAL_NONE);
104 bool AddLocal(const CNetAddr& addr, int nScore = LOCAL_NONE);
105 bool SeenLocal(const CService& addr);
106 bool IsLocal(const CService& addr);
107 bool GetLocal(CService &addr, const CNetAddr *paddrPeer = NULL);
108 bool IsReachable(const CNetAddr &addr);
109 void SetReachable(enum Network net, bool fFlag = true);
110 CAddress GetLocalAddress(const CNetAddr *paddrPeer = NULL);
111
112
113 extern bool fDiscover;
114 extern bool fListen;
115 extern uint64_t nLocalServices;
116 extern uint64_t nLocalHostNonce;
117 extern CAddrMan addrman;
118 extern int nMaxConnections;
119
120 extern std::vector<CNode*> vNodes;
121 extern CCriticalSection cs_vNodes;
122 extern std::map<CInv, CDataStream> mapRelay;
123 extern std::deque<std::pair<int64_t, CInv> > vRelayExpiration;
124 extern CCriticalSection cs_mapRelay;
125 extern limitedmap<CInv, int64_t> mapAlreadyAskedFor;
126
127 extern std::vector<std::string> vAddedNodes;
128 extern CCriticalSection cs_vAddedNodes;
129
130 extern NodeId nLastNodeId;
131 extern CCriticalSection cs_nLastNodeId;
132
133 struct LocalServiceInfo {
134     int nScore;
135     int nPort;
136 };
137
138 extern CCriticalSection cs_mapLocalHost;
139 extern std::map<CNetAddr, LocalServiceInfo> mapLocalHost;
140
141 class CNodeStats
142 {
143 public:
144     NodeId nodeid;
145     uint64_t nServices;
146     int64_t nLastSend;
147     int64_t nLastRecv;
148     int64_t nTimeConnected;
149     std::string addrName;
150     int nVersion;
151     std::string cleanSubVer;
152     bool fInbound;
153     int nStartingHeight;
154     uint64_t nSendBytes;
155     uint64_t nRecvBytes;
156     bool fSyncNode;
157     bool fWhitelisted;
158     double dPingTime;
159     double dPingWait;
160     std::string addrLocal;
161 };
162
163
164
165
166 class CNetMessage {
167 public:
168     bool in_data;                   // parsing header (false) or data (true)
169
170     CDataStream hdrbuf;             // partially received header
171     CMessageHeader hdr;             // complete header
172     unsigned int nHdrPos;
173
174     CDataStream vRecv;              // received message data
175     unsigned int nDataPos;
176
177     int64_t nTime;                  // time (in microseconds) of message receipt.
178
179     CNetMessage(int nTypeIn, int nVersionIn) : hdrbuf(nTypeIn, nVersionIn), vRecv(nTypeIn, nVersionIn) {
180         hdrbuf.resize(24);
181         in_data = false;
182         nHdrPos = 0;
183         nDataPos = 0;
184         nTime = 0;
185     }
186
187     bool complete() const
188     {
189         if (!in_data)
190             return false;
191         return (hdr.nMessageSize == nDataPos);
192     }
193
194     void SetVersion(int nVersionIn)
195     {
196         hdrbuf.SetVersion(nVersionIn);
197         vRecv.SetVersion(nVersionIn);
198     }
199
200     int readHeader(const char *pch, unsigned int nBytes);
201     int readData(const char *pch, unsigned int nBytes);
202 };
203
204
205
206
207
208 /** Information about a peer */
209 class CNode
210 {
211 public:
212     // socket
213     uint64_t nServices;
214     SOCKET hSocket;
215     CDataStream ssSend;
216     size_t nSendSize; // total size of all vSendMsg entries
217     size_t nSendOffset; // offset inside the first vSendMsg already sent
218     uint64_t nSendBytes;
219     std::deque<CSerializeData> vSendMsg;
220     CCriticalSection cs_vSend;
221
222     std::deque<CInv> vRecvGetData;
223     std::deque<CNetMessage> vRecvMsg;
224     CCriticalSection cs_vRecvMsg;
225     uint64_t nRecvBytes;
226     int nRecvVersion;
227
228     int64_t nLastSend;
229     int64_t nLastRecv;
230     int64_t nTimeConnected;
231     CAddress addr;
232     std::string addrName;
233     CService addrLocal;
234     int nVersion;
235     // strSubVer is whatever byte array we read from the wire. However, this field is intended
236     // to be printed out, displayed to humans in various forms and so on. So we sanitize it and
237     // store the sanitized version in cleanSubVer. The original should be used when dealing with
238     // the network or wire types and the cleaned string used when displayed or logged.
239     std::string strSubVer, cleanSubVer;
240     bool fWhitelisted; // This peer can bypass DoS banning.
241     bool fOneShot;
242     bool fClient;
243     bool fInbound;
244     bool fNetworkNode;
245     bool fSuccessfullyConnected;
246     bool fDisconnect;
247     // We use fRelayTxes for two purposes -
248     // a) it allows us to not relay tx invs before receiving the peer's version message
249     // b) the peer may tell us in their version message that we should not relay tx invs
250     //    until they have initialized their bloom filter.
251     bool fRelayTxes;
252     CSemaphoreGrant grantOutbound;
253     CCriticalSection cs_filter;
254     CBloomFilter* pfilter;
255     int nRefCount;
256     NodeId id;
257 protected:
258
259     // Denial-of-service detection/prevention
260     // Key is IP address, value is banned-until-time
261     static std::map<CNetAddr, int64_t> setBanned;
262     static CCriticalSection cs_setBanned;
263
264     // Whitelisted ranges. Any node connecting from these is automatically
265     // whitelisted (as well as those connecting to whitelisted binds).
266     static std::vector<CSubNet> vWhitelistedRange;
267     static CCriticalSection cs_vWhitelistedRange;
268
269     // Basic fuzz-testing
270     void Fuzz(int nChance); // modifies ssSend
271
272 public:
273     uint256 hashContinue;
274     CBlockIndex* pindexLastGetBlocksBegin;
275     uint256 hashLastGetBlocksEnd;
276     int nStartingHeight;
277     bool fStartSync;
278
279     // flood relay
280     std::vector<CAddress> vAddrToSend;
281     mruset<CAddress> setAddrKnown;
282     bool fGetAddr;
283     std::set<uint256> setKnown;
284
285     // inventory based relay
286     mruset<CInv> setInventoryKnown;
287     std::vector<CInv> vInventoryToSend;
288     CCriticalSection cs_inventory;
289     std::multimap<int64_t, CInv> mapAskFor;
290
291     // Ping time measurement:
292     // The pong reply we're expecting, or 0 if no pong expected.
293     uint64_t nPingNonceSent;
294     // Time (in usec) the last ping was sent, or 0 if no ping was ever sent.
295     int64_t nPingUsecStart;
296     // Last measured round-trip time.
297     int64_t nPingUsecTime;
298     // Whether a ping is requested.
299     bool fPingQueued;
300
301     CNode(SOCKET hSocketIn, CAddress addrIn, std::string addrNameIn = "", bool fInboundIn=false) : ssSend(SER_NETWORK, INIT_PROTO_VERSION), setAddrKnown(5000)
302     {
303         nServices = 0;
304         hSocket = hSocketIn;
305         nRecvVersion = INIT_PROTO_VERSION;
306         nLastSend = 0;
307         nLastRecv = 0;
308         nSendBytes = 0;
309         nRecvBytes = 0;
310         nTimeConnected = GetTime();
311         addr = addrIn;
312         addrName = addrNameIn == "" ? addr.ToStringIPPort() : addrNameIn;
313         nVersion = 0;
314         strSubVer = "";
315         fWhitelisted = false;
316         fOneShot = false;
317         fClient = false; // set by version message
318         fInbound = fInboundIn;
319         fNetworkNode = false;
320         fSuccessfullyConnected = false;
321         fDisconnect = false;
322         nRefCount = 0;
323         nSendSize = 0;
324         nSendOffset = 0;
325         hashContinue = 0;
326         pindexLastGetBlocksBegin = 0;
327         hashLastGetBlocksEnd = 0;
328         nStartingHeight = -1;
329         fStartSync = false;
330         fGetAddr = false;
331         fRelayTxes = false;
332         setInventoryKnown.max_size(SendBufferSize() / 1000);
333         pfilter = new CBloomFilter();
334         nPingNonceSent = 0;
335         nPingUsecStart = 0;
336         nPingUsecTime = 0;
337         fPingQueued = false;
338
339         {
340             LOCK(cs_nLastNodeId);
341             id = nLastNodeId++;
342         }
343
344         if (fLogIPs)
345             LogPrint("net", "Added connection to %s peer=%d\n", addrName, id);
346         else
347             LogPrint("net", "Added connection peer=%d\n", id);
348
349         // Be shy and don't send version until we hear
350         if (hSocket != INVALID_SOCKET && !fInbound)
351             PushVersion();
352
353         GetNodeSignals().InitializeNode(GetId(), this);
354     }
355
356     ~CNode()
357     {
358         if (hSocket != INVALID_SOCKET)
359         {
360             CloseSocket(hSocket);
361         }
362         if (pfilter)
363             delete pfilter;
364         GetNodeSignals().FinalizeNode(GetId());
365     }
366
367 private:
368     // Network usage totals
369     static CCriticalSection cs_totalBytesRecv;
370     static CCriticalSection cs_totalBytesSent;
371     static uint64_t nTotalBytesRecv;
372     static uint64_t nTotalBytesSent;
373
374     CNode(const CNode&);
375     void operator=(const CNode&);
376
377 public:
378
379     NodeId GetId() const {
380       return id;
381     }
382
383     int GetRefCount()
384     {
385         assert(nRefCount >= 0);
386         return nRefCount;
387     }
388
389     // requires LOCK(cs_vRecvMsg)
390     unsigned int GetTotalRecvSize()
391     {
392         unsigned int total = 0;
393         BOOST_FOREACH(const CNetMessage &msg, vRecvMsg)
394             total += msg.vRecv.size() + 24;
395         return total;
396     }
397
398     // requires LOCK(cs_vRecvMsg)
399     bool ReceiveMsgBytes(const char *pch, unsigned int nBytes);
400
401     // requires LOCK(cs_vRecvMsg)
402     void SetRecvVersion(int nVersionIn)
403     {
404         nRecvVersion = nVersionIn;
405         BOOST_FOREACH(CNetMessage &msg, vRecvMsg)
406             msg.SetVersion(nVersionIn);
407     }
408
409     CNode* AddRef()
410     {
411         nRefCount++;
412         return this;
413     }
414
415     void Release()
416     {
417         nRefCount--;
418     }
419
420
421
422     void AddAddressKnown(const CAddress& addr)
423     {
424         setAddrKnown.insert(addr);
425     }
426
427     void PushAddress(const CAddress& addr)
428     {
429         // Known checking here is only to save space from duplicates.
430         // SendMessages will filter it again for knowns that were added
431         // after addresses were pushed.
432         if (addr.IsValid() && !setAddrKnown.count(addr))
433             vAddrToSend.push_back(addr);
434     }
435
436
437     void AddInventoryKnown(const CInv& inv)
438     {
439         {
440             LOCK(cs_inventory);
441             setInventoryKnown.insert(inv);
442         }
443     }
444
445     void PushInventory(const CInv& inv)
446     {
447         {
448             LOCK(cs_inventory);
449             if (!setInventoryKnown.count(inv))
450                 vInventoryToSend.push_back(inv);
451         }
452     }
453
454     void AskFor(const CInv& inv)
455     {
456         // We're using mapAskFor as a priority queue,
457         // the key is the earliest time the request can be sent
458         int64_t nRequestTime;
459         limitedmap<CInv, int64_t>::const_iterator it = mapAlreadyAskedFor.find(inv);
460         if (it != mapAlreadyAskedFor.end())
461             nRequestTime = it->second;
462         else
463             nRequestTime = 0;
464         LogPrint("net", "askfor %s  %d (%s) peer=%d\n", inv.ToString(), nRequestTime, DateTimeStrFormat("%H:%M:%S", nRequestTime/1000000).c_str(), id);
465
466         // Make sure not to reuse time indexes to keep things in the same order
467         int64_t nNow = GetTimeMicros() - 1000000;
468         static int64_t nLastTime;
469         ++nLastTime;
470         nNow = std::max(nNow, nLastTime);
471         nLastTime = nNow;
472
473         // Each retry is 2 minutes after the last
474         nRequestTime = std::max(nRequestTime + 2 * 60 * 1000000, nNow);
475         if (it != mapAlreadyAskedFor.end())
476             mapAlreadyAskedFor.update(it, nRequestTime);
477         else
478             mapAlreadyAskedFor.insert(std::make_pair(inv, nRequestTime));
479         mapAskFor.insert(std::make_pair(nRequestTime, inv));
480     }
481
482
483
484     // TODO: Document the postcondition of this function.  Is cs_vSend locked?
485     void BeginMessage(const char* pszCommand) EXCLUSIVE_LOCK_FUNCTION(cs_vSend)
486     {
487         ENTER_CRITICAL_SECTION(cs_vSend);
488         assert(ssSend.size() == 0);
489         ssSend << CMessageHeader(pszCommand, 0);
490         LogPrint("net", "sending: %s ", pszCommand);
491     }
492
493     // TODO: Document the precondition of this function.  Is cs_vSend locked?
494     void AbortMessage() UNLOCK_FUNCTION(cs_vSend)
495     {
496         ssSend.clear();
497
498         LEAVE_CRITICAL_SECTION(cs_vSend);
499
500         LogPrint("net", "(aborted)\n");
501     }
502
503     // TODO: Document the precondition of this function.  Is cs_vSend locked?
504     void EndMessage() UNLOCK_FUNCTION(cs_vSend)
505     {
506         // The -*messagestest options are intentionally not documented in the help message,
507         // since they are only used during development to debug the networking code and are
508         // not intended for end-users.
509         if (mapArgs.count("-dropmessagestest") && GetRand(GetArg("-dropmessagestest", 2)) == 0)
510         {
511             LogPrint("net", "dropmessages DROPPING SEND MESSAGE\n");
512             AbortMessage();
513             return;
514         }
515         if (mapArgs.count("-fuzzmessagestest"))
516             Fuzz(GetArg("-fuzzmessagestest", 10));
517
518         if (ssSend.size() == 0)
519             return;
520
521         // Set the size
522         unsigned int nSize = ssSend.size() - CMessageHeader::HEADER_SIZE;
523         memcpy((char*)&ssSend[CMessageHeader::MESSAGE_SIZE_OFFSET], &nSize, sizeof(nSize));
524
525         // Set the checksum
526         uint256 hash = Hash(ssSend.begin() + CMessageHeader::HEADER_SIZE, ssSend.end());
527         unsigned int nChecksum = 0;
528         memcpy(&nChecksum, &hash, sizeof(nChecksum));
529         assert(ssSend.size () >= CMessageHeader::CHECKSUM_OFFSET + sizeof(nChecksum));
530         memcpy((char*)&ssSend[CMessageHeader::CHECKSUM_OFFSET], &nChecksum, sizeof(nChecksum));
531
532         LogPrint("net", "(%d bytes) peer=%d\n", nSize, id);
533
534         std::deque<CSerializeData>::iterator it = vSendMsg.insert(vSendMsg.end(), CSerializeData());
535         ssSend.GetAndClear(*it);
536         nSendSize += (*it).size();
537
538         // If write queue empty, attempt "optimistic write"
539         if (it == vSendMsg.begin())
540             SocketSendData(this);
541
542         LEAVE_CRITICAL_SECTION(cs_vSend);
543     }
544
545     void PushVersion();
546
547
548     void PushMessage(const char* pszCommand)
549     {
550         try
551         {
552             BeginMessage(pszCommand);
553             EndMessage();
554         }
555         catch (...)
556         {
557             AbortMessage();
558             throw;
559         }
560     }
561
562     template<typename T1>
563     void PushMessage(const char* pszCommand, const T1& a1)
564     {
565         try
566         {
567             BeginMessage(pszCommand);
568             ssSend << a1;
569             EndMessage();
570         }
571         catch (...)
572         {
573             AbortMessage();
574             throw;
575         }
576     }
577
578     template<typename T1, typename T2>
579     void PushMessage(const char* pszCommand, const T1& a1, const T2& a2)
580     {
581         try
582         {
583             BeginMessage(pszCommand);
584             ssSend << a1 << a2;
585             EndMessage();
586         }
587         catch (...)
588         {
589             AbortMessage();
590             throw;
591         }
592     }
593
594     template<typename T1, typename T2, typename T3>
595     void PushMessage(const char* pszCommand, const T1& a1, const T2& a2, const T3& a3)
596     {
597         try
598         {
599             BeginMessage(pszCommand);
600             ssSend << a1 << a2 << a3;
601             EndMessage();
602         }
603         catch (...)
604         {
605             AbortMessage();
606             throw;
607         }
608     }
609
610     template<typename T1, typename T2, typename T3, typename T4>
611     void PushMessage(const char* pszCommand, const T1& a1, const T2& a2, const T3& a3, const T4& a4)
612     {
613         try
614         {
615             BeginMessage(pszCommand);
616             ssSend << a1 << a2 << a3 << a4;
617             EndMessage();
618         }
619         catch (...)
620         {
621             AbortMessage();
622             throw;
623         }
624     }
625
626     template<typename T1, typename T2, typename T3, typename T4, typename T5>
627     void PushMessage(const char* pszCommand, const T1& a1, const T2& a2, const T3& a3, const T4& a4, const T5& a5)
628     {
629         try
630         {
631             BeginMessage(pszCommand);
632             ssSend << a1 << a2 << a3 << a4 << a5;
633             EndMessage();
634         }
635         catch (...)
636         {
637             AbortMessage();
638             throw;
639         }
640     }
641
642     template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
643     void PushMessage(const char* pszCommand, const T1& a1, const T2& a2, const T3& a3, const T4& a4, const T5& a5, const T6& a6)
644     {
645         try
646         {
647             BeginMessage(pszCommand);
648             ssSend << a1 << a2 << a3 << a4 << a5 << a6;
649             EndMessage();
650         }
651         catch (...)
652         {
653             AbortMessage();
654             throw;
655         }
656     }
657
658     template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
659     void PushMessage(const char* pszCommand, const T1& a1, const T2& a2, const T3& a3, const T4& a4, const T5& a5, const T6& a6, const T7& a7)
660     {
661         try
662         {
663             BeginMessage(pszCommand);
664             ssSend << a1 << a2 << a3 << a4 << a5 << a6 << a7;
665             EndMessage();
666         }
667         catch (...)
668         {
669             AbortMessage();
670             throw;
671         }
672     }
673
674     template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
675     void PushMessage(const char* pszCommand, const T1& a1, const T2& a2, const T3& a3, const T4& a4, const T5& a5, const T6& a6, const T7& a7, const T8& a8)
676     {
677         try
678         {
679             BeginMessage(pszCommand);
680             ssSend << a1 << a2 << a3 << a4 << a5 << a6 << a7 << a8;
681             EndMessage();
682         }
683         catch (...)
684         {
685             AbortMessage();
686             throw;
687         }
688     }
689
690     template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9>
691     void PushMessage(const char* pszCommand, const T1& a1, const T2& a2, const T3& a3, const T4& a4, const T5& a5, const T6& a6, const T7& a7, const T8& a8, const T9& a9)
692     {
693         try
694         {
695             BeginMessage(pszCommand);
696             ssSend << a1 << a2 << a3 << a4 << a5 << a6 << a7 << a8 << a9;
697             EndMessage();
698         }
699         catch (...)
700         {
701             AbortMessage();
702             throw;
703         }
704     }
705
706     bool IsSubscribed(unsigned int nChannel);
707     void Subscribe(unsigned int nChannel, unsigned int nHops=0);
708     void CancelSubscribe(unsigned int nChannel);
709     void CloseSocketDisconnect();
710
711     // Denial-of-service detection/prevention
712     // The idea is to detect peers that are behaving
713     // badly and disconnect/ban them, but do it in a
714     // one-coding-mistake-won't-shatter-the-entire-network
715     // way.
716     // IMPORTANT:  There should be nothing I can give a
717     // node that it will forward on that will make that
718     // node's peers drop it. If there is, an attacker
719     // can isolate a node and/or try to split the network.
720     // Dropping a node for sending stuff that is invalid
721     // now but might be valid in a later version is also
722     // dangerous, because it can cause a network split
723     // between nodes running old code and nodes running
724     // new code.
725     static void ClearBanned(); // needed for unit testing
726     static bool IsBanned(CNetAddr ip);
727     static bool Ban(const CNetAddr &ip);
728     void copyStats(CNodeStats &stats);
729
730     static bool IsWhitelistedRange(const CNetAddr &ip);
731     static void AddWhitelistedRange(const CSubNet &subnet);
732
733     // Network stats
734     static void RecordBytesRecv(uint64_t bytes);
735     static void RecordBytesSent(uint64_t bytes);
736
737     static uint64_t GetTotalBytesRecv();
738     static uint64_t GetTotalBytesSent();
739 };
740
741
742
743 class CTransaction;
744 void RelayTransaction(const CTransaction& tx);
745 void RelayTransaction(const CTransaction& tx, const CDataStream& ss);
746
747 /** Access to the (IP) address database (peers.dat) */
748 class CAddrDB
749 {
750 private:
751     boost::filesystem::path pathAddr;
752 public:
753     CAddrDB();
754     bool Write(const CAddrMan& addr);
755     bool Read(CAddrMan& addr);
756 };
757
758 #endif
This page took 0.067946 seconds and 4 git commands to generate.