Dash Core  0.12.2.1
P2P Digital Currency
netfulfilledman.cpp
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 #include "chainparams.h"
6 #include "netfulfilledman.h"
7 #include "util.h"
8 
10 
12 {
15 }
16 
18 {
20  fulfilledreqmap_t::iterator it = mapFulfilledRequests.find(addr);
21 
22  return it != mapFulfilledRequests.end() &&
23  it->second.find(strRequest) != it->second.end() &&
24  it->second[strRequest] > GetTime();
25 }
26 
28 {
30  fulfilledreqmap_t::iterator it = mapFulfilledRequests.find(addr);
31 
32  if (it != mapFulfilledRequests.end()) {
33  it->second.erase(strRequest);
34  }
35 }
36 
38 {
40 
41  int64_t now = GetTime();
42  fulfilledreqmap_t::iterator it = mapFulfilledRequests.begin();
43 
44  while(it != mapFulfilledRequests.end()) {
45  fulfilledreqmapentry_t::iterator it_entry = it->second.begin();
46  while(it_entry != it->second.end()) {
47  if(now > it_entry->second) {
48  it->second.erase(it_entry++);
49  } else {
50  ++it_entry;
51  }
52  }
53  if(it->second.size() == 0) {
54  mapFulfilledRequests.erase(it++);
55  } else {
56  ++it;
57  }
58  }
59 }
60 
62 {
64  mapFulfilledRequests.clear();
65 }
66 
68 {
69  std::ostringstream info;
70  info << "Nodes with fulfilled requests: " << (int)mapFulfilledRequests.size();
71  return info.str();
72 }
void AddFulfilledRequest(CAddress addr, std::string strRequest)
bool HasFulfilledRequest(CAddress addr, std::string strRequest)
std::string ToString() const
int FulfilledRequestExpireTime() const
Definition: chainparams.h:82
#define LOCK(cs)
Definition: sync.h:168
fulfilledreqmap_t mapFulfilledRequests
CCriticalSection cs_mapFulfilledRequests
const CChainParams & Params()
void RemoveFulfilledRequest(CAddress addr, std::string strRequest)
CNetFulfilledRequestManager netfulfilledman
int64_t GetTime()
For unit testing.
Definition: utiltime.cpp:20