fix verification network behaviour: (#1348)
* fix verification network behaviour: - use up to 10 connections only - save state (do not ask same nodes after restart) - initiate on time based intervals (every 5 minutes), based not on new blocks (should keep connections alive longer) * revert mWeAskedForVerification serialization * send verify requests using MAX_POSE_CONNECTIONS as a step
This commit is contained in:
parent
31d8e03a2b
commit
91f7e57402
@ -2527,6 +2527,9 @@ void ThreadCheckDarkSendPool()
|
|||||||
mnpayments.CheckAndRemove();
|
mnpayments.CheckAndRemove();
|
||||||
instantsend.CheckAndRemove();
|
instantsend.CheckAndRemove();
|
||||||
}
|
}
|
||||||
|
if(fMasterNode && (nTick % (60 * 5) == 0)) {
|
||||||
|
mnodeman.DoFullVerificationStep();
|
||||||
|
}
|
||||||
|
|
||||||
darkSendPool.CheckTimeout();
|
darkSendPool.CheckTimeout();
|
||||||
darkSendPool.CheckForCompleteQueue();
|
darkSendPool.CheckForCompleteQueue();
|
||||||
|
@ -102,6 +102,9 @@ CMasternodeMan::CMasternodeMan()
|
|||||||
mAskedUsForMasternodeList(),
|
mAskedUsForMasternodeList(),
|
||||||
mWeAskedForMasternodeList(),
|
mWeAskedForMasternodeList(),
|
||||||
mWeAskedForMasternodeListEntry(),
|
mWeAskedForMasternodeListEntry(),
|
||||||
|
mWeAskedForVerification(),
|
||||||
|
mMnbRecoveryRequests(),
|
||||||
|
mMnbRecoveryGoodReplies(),
|
||||||
listScheduledMnbRequestConnections(),
|
listScheduledMnbRequestConnections(),
|
||||||
nLastIndexRebuildTime(0),
|
nLastIndexRebuildTime(0),
|
||||||
indexMasternodes(),
|
indexMasternodes(),
|
||||||
@ -967,7 +970,6 @@ void CMasternodeMan::DoFullVerificationStep()
|
|||||||
LOCK2(cs_main, cs);
|
LOCK2(cs_main, cs);
|
||||||
|
|
||||||
int nCount = 0;
|
int nCount = 0;
|
||||||
int nCountMax = std::max(10, (int)vMasternodes.size() / 100); // verify at least 10 masternode at once but at most 1% of all known masternodes
|
|
||||||
|
|
||||||
int nMyRank = -1;
|
int nMyRank = -1;
|
||||||
int nRanksTotal = (int)vecMasternodeRanks.size();
|
int nRanksTotal = (int)vecMasternodeRanks.size();
|
||||||
@ -983,7 +985,7 @@ void CMasternodeMan::DoFullVerificationStep()
|
|||||||
if(it->second.vin == activeMasternode.vin) {
|
if(it->second.vin == activeMasternode.vin) {
|
||||||
nMyRank = it->first;
|
nMyRank = it->first;
|
||||||
LogPrint("masternode", "CMasternodeMan::DoFullVerificationStep -- Found self at rank %d/%d, verifying up to %d masternodes\n",
|
LogPrint("masternode", "CMasternodeMan::DoFullVerificationStep -- Found self at rank %d/%d, verifying up to %d masternodes\n",
|
||||||
nMyRank, nRanksTotal, nCountMax);
|
nMyRank, nRanksTotal, (int)MAX_POSE_CONNECTIONS);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
++it;
|
++it;
|
||||||
@ -992,9 +994,9 @@ void CMasternodeMan::DoFullVerificationStep()
|
|||||||
// edge case: list is too short and this masternode is not enabled
|
// edge case: list is too short and this masternode is not enabled
|
||||||
if(nMyRank == -1) return;
|
if(nMyRank == -1) return;
|
||||||
|
|
||||||
// send verify requests to up to nCountMax masternodes starting from
|
// send verify requests to up to MAX_POSE_CONNECTIONS masternodes
|
||||||
// (MAX_POSE_RANK + nCountMax * (nMyRank - 1) + 1)
|
// starting from MAX_POSE_RANK + nMyRank and using MAX_POSE_CONNECTIONS as a step
|
||||||
int nOffset = MAX_POSE_RANK + nCountMax * (nMyRank - 1);
|
int nOffset = MAX_POSE_RANK + nMyRank - 1;
|
||||||
if(nOffset >= (int)vecMasternodeRanks.size()) return;
|
if(nOffset >= (int)vecMasternodeRanks.size()) return;
|
||||||
|
|
||||||
std::vector<CMasternode*> vSortedByAddr;
|
std::vector<CMasternode*> vSortedByAddr;
|
||||||
@ -1012,16 +1014,20 @@ void CMasternodeMan::DoFullVerificationStep()
|
|||||||
it->second.IsPoSeVerified() && it->second.IsPoSeBanned() ? " and " : "",
|
it->second.IsPoSeVerified() && it->second.IsPoSeBanned() ? " and " : "",
|
||||||
it->second.IsPoSeBanned() ? "banned" : "",
|
it->second.IsPoSeBanned() ? "banned" : "",
|
||||||
it->second.vin.prevout.ToStringShort(), it->second.addr.ToString());
|
it->second.vin.prevout.ToStringShort(), it->second.addr.ToString());
|
||||||
++it;
|
nOffset += MAX_POSE_CONNECTIONS;
|
||||||
|
if(nOffset >= (int)vecMasternodeRanks.size()) break;
|
||||||
|
it += MAX_POSE_CONNECTIONS;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
LogPrint("masternode", "CMasternodeMan::DoFullVerificationStep -- Verifying masternode %s rank %d/%d address %s\n",
|
LogPrint("masternode", "CMasternodeMan::DoFullVerificationStep -- Verifying masternode %s rank %d/%d address %s\n",
|
||||||
it->second.vin.prevout.ToStringShort(), it->first, nRanksTotal, it->second.addr.ToString());
|
it->second.vin.prevout.ToStringShort(), it->first, nRanksTotal, it->second.addr.ToString());
|
||||||
if(SendVerifyRequest((CAddress)it->second.addr, vSortedByAddr)) {
|
if(SendVerifyRequest((CAddress)it->second.addr, vSortedByAddr)) {
|
||||||
nCount++;
|
nCount++;
|
||||||
if(nCount >= nCountMax) break;
|
if(nCount >= MAX_POSE_CONNECTIONS) break;
|
||||||
}
|
}
|
||||||
++it;
|
nOffset += MAX_POSE_CONNECTIONS;
|
||||||
|
if(nOffset >= (int)vecMasternodeRanks.size()) break;
|
||||||
|
it += MAX_POSE_CONNECTIONS;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogPrint("masternode", "CMasternodeMan::DoFullVerificationStep -- Sent verification requests to %d masternodes\n", nCount);
|
LogPrint("masternode", "CMasternodeMan::DoFullVerificationStep -- Sent verification requests to %d masternodes\n", nCount);
|
||||||
@ -1640,7 +1646,6 @@ void CMasternodeMan::UpdatedBlockTip(const CBlockIndex *pindex)
|
|||||||
CheckSameAddr();
|
CheckSameAddr();
|
||||||
|
|
||||||
if(fMasterNode) {
|
if(fMasterNode) {
|
||||||
DoFullVerificationStep();
|
|
||||||
// normal wallet does not need to update this every block, doing update on rpc call should be enough
|
// normal wallet does not need to update this every block, doing update on rpc call should be enough
|
||||||
UpdateLastPaid();
|
UpdateLastPaid();
|
||||||
}
|
}
|
||||||
|
@ -100,6 +100,7 @@ private:
|
|||||||
static const int LAST_PAID_SCAN_BLOCKS = 100;
|
static const int LAST_PAID_SCAN_BLOCKS = 100;
|
||||||
|
|
||||||
static const int MIN_POSE_PROTO_VERSION = 70203;
|
static const int MIN_POSE_PROTO_VERSION = 70203;
|
||||||
|
static const int MAX_POSE_CONNECTIONS = 10;
|
||||||
static const int MAX_POSE_RANK = 10;
|
static const int MAX_POSE_RANK = 10;
|
||||||
static const int MAX_POSE_BLOCKS = 10;
|
static const int MAX_POSE_BLOCKS = 10;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user