Dash Core  0.12.2.1
P2P Digital Currency
netfulfilledman.h
Go to the documentation of this file.
1 // Copyright (c) 2014-2017 The Dash Core developers
2 // Distributed under the MIT/X11 software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #ifndef NETFULFILLEDMAN_H
6 #define NETFULFILLEDMAN_H
7 
8 #include "netbase.h"
9 #include "protocol.h"
10 #include "serialize.h"
11 #include "sync.h"
12 
15 
16 // Fulfilled requests are used to prevent nodes from asking for the same data on sync
17 // and from being banned for doing so too often.
19 {
20 private:
21  typedef std::map<std::string, int64_t> fulfilledreqmapentry_t;
22  typedef std::map<CNetAddr, fulfilledreqmapentry_t> fulfilledreqmap_t;
23 
24  //keep track of what node has/was asked for and when
27 
28 public:
30 
32 
33  template <typename Stream, typename Operation>
34  inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
37  }
38 
39  void AddFulfilledRequest(CAddress addr, std::string strRequest); // expire after 1 hour by default
40  bool HasFulfilledRequest(CAddress addr, std::string strRequest);
41  void RemoveFulfilledRequest(CAddress addr, std::string strRequest);
42 
43  void CheckAndRemove();
44  void Clear();
45 
46  std::string ToString() const;
47 };
48 
49 #endif
#define READWRITE(obj)
Definition: serialize.h:175
void AddFulfilledRequest(CAddress addr, std::string strRequest)
void SerializationOp(Stream &s, Operation ser_action, int nType, int nVersion)
bool HasFulfilledRequest(CAddress addr, std::string strRequest)
std::string ToString() const
std::map< std::string, int64_t > fulfilledreqmapentry_t
std::map< CNetAddr, fulfilledreqmapentry_t > fulfilledreqmap_t
#define LOCK(cs)
Definition: sync.h:168
fulfilledreqmap_t mapFulfilledRequests
CCriticalSection cs_mapFulfilledRequests
void RemoveFulfilledRequest(CAddress addr, std::string strRequest)
CNetFulfilledRequestManager netfulfilledman