Fix netfulfilledman usage (#2033)

* drop CMasternodeSync::ClearFulfilledRequests()

* Cleanup netfulfilledman periodically

* Do not expose RemoveFulfilledRequest()
This commit is contained in:
UdjinM6 2018-04-18 14:49:25 +03:00 committed by GitHub
parent 53093c65be
commit a37dbd6d2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 4 additions and 15 deletions

View File

@ -64,12 +64,10 @@ void CMasternodeSync::SwitchToNextAsset(CConnman& connman)
throw std::runtime_error("Can't switch to next asset from failed, should use Reset() first!");
break;
case(MASTERNODE_SYNC_INITIAL):
ClearFulfilledRequests(connman);
nRequestedMasternodeAssets = MASTERNODE_SYNC_WAITING;
LogPrintf("CMasternodeSync::SwitchToNextAsset -- Starting %s\n", GetAssetName());
break;
case(MASTERNODE_SYNC_WAITING):
ClearFulfilledRequests(connman);
LogPrintf("CMasternodeSync::SwitchToNextAsset -- Completed %s in %llds\n", GetAssetName(), GetTime() - nTimeAssetSyncStarted);
nRequestedMasternodeAssets = MASTERNODE_SYNC_LIST;
LogPrintf("CMasternodeSync::SwitchToNextAsset -- Starting %s\n", GetAssetName());
@ -132,17 +130,6 @@ void CMasternodeSync::ProcessMessage(CNode* pfrom, const std::string& strCommand
}
}
void CMasternodeSync::ClearFulfilledRequests(CConnman& connman)
{
connman.ForEachNode(CConnman::AllNodes, [](CNode* pnode) {
netfulfilledman.RemoveFulfilledRequest(pnode->addr, "spork-sync");
netfulfilledman.RemoveFulfilledRequest(pnode->addr, "masternode-list-sync");
netfulfilledman.RemoveFulfilledRequest(pnode->addr, "masternode-payment-sync");
netfulfilledman.RemoveFulfilledRequest(pnode->addr, "governance-sync");
netfulfilledman.RemoveFulfilledRequest(pnode->addr, "full-sync");
});
}
void CMasternodeSync::ProcessTick(CConnman& connman)
{
static int nTick = 0;

View File

@ -48,7 +48,6 @@ private:
int64_t nTimeLastFailure;
void Fail();
void ClearFulfilledRequests(CConnman& connman);
public:
CMasternodeSync() { Reset(); }

View File

@ -24,6 +24,8 @@ private:
fulfilledreqmap_t mapFulfilledRequests;
CCriticalSection cs_mapFulfilledRequests;
void RemoveFulfilledRequest(const CService& addr, const std::string& strRequest);
public:
CNetFulfilledRequestManager() {}
@ -37,7 +39,6 @@ public:
void AddFulfilledRequest(const CService& addr, const std::string& strRequest);
bool HasFulfilledRequest(const CService& addr, const std::string& strRequest);
void RemoveFulfilledRequest(const CService& addr, const std::string& strRequest);
void CheckAndRemove();
void Clear();

View File

@ -12,6 +12,7 @@
#include "masternode-sync.h"
#include "masternodeman.h"
#include "messagesigner.h"
#include "netfulfilledman.h"
#include "netmessagemaker.h"
#include "script/sign.h"
#include "txmempool.h"
@ -545,6 +546,7 @@ void ThreadCheckPrivateSend(CConnman& connman)
activeMasternode.ManageState(connman);
if(nTick % 60 == 0) {
netfulfilledman.CheckAndRemove();
mnodeman.ProcessMasternodeConnections(connman);
mnodeman.CheckAndRemove(connman);
mnodeman.WarnMasternodeDaemonUpdates();