mirror of
https://github.com/dashpay/dash.git
synced 2024-12-29 13:59:06 +01:00
50 lines
1.4 KiB
C++
50 lines
1.4 KiB
C++
// Copyright (c) 2014-2022 The Dash Core developers
|
|
// Distributed under the MIT/X11 software license, see the accompanying
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
#ifndef BITCOIN_NETFULFILLEDMAN_H
|
|
#define BITCOIN_NETFULFILLEDMAN_H
|
|
|
|
#include <netaddress.h>
|
|
#include <serialize.h>
|
|
#include <sync.h>
|
|
|
|
class CNetFulfilledRequestManager;
|
|
extern CNetFulfilledRequestManager netfulfilledman;
|
|
|
|
// Fulfilled requests are used to prevent nodes from asking for the same data on sync
|
|
// and from being banned for doing so too often.
|
|
class CNetFulfilledRequestManager
|
|
{
|
|
private:
|
|
typedef std::map<std::string, int64_t> fulfilledreqmapentry_t;
|
|
typedef std::map<CService, fulfilledreqmapentry_t> fulfilledreqmap_t;
|
|
|
|
//keep track of what node has/was asked for and when
|
|
fulfilledreqmap_t mapFulfilledRequests;
|
|
mutable CCriticalSection cs_mapFulfilledRequests;
|
|
|
|
public:
|
|
CNetFulfilledRequestManager() {}
|
|
|
|
SERIALIZE_METHODS(CNetFulfilledRequestManager, obj)
|
|
{
|
|
LOCK(obj.cs_mapFulfilledRequests);
|
|
READWRITE(obj.mapFulfilledRequests);
|
|
}
|
|
|
|
void AddFulfilledRequest(const CService& addr, const std::string& strRequest);
|
|
bool HasFulfilledRequest(const CService& addr, const std::string& strRequest);
|
|
|
|
void RemoveAllFulfilledRequests(const CService& addr);
|
|
|
|
void CheckAndRemove();
|
|
void Clear();
|
|
|
|
std::string ToString() const;
|
|
|
|
void DoMaintenance();
|
|
};
|
|
|
|
#endif // BITCOIN_NETFULFILLEDMAN_H
|