Move LLMQ connection retry timeout into chainparams

This commit is contained in:
Alexander Block 2020-03-21 12:21:09 +01:00
parent 458a63736d
commit 2a6465a6fb
3 changed files with 10 additions and 1 deletions

View File

@ -395,6 +395,7 @@ public:
fMineBlocksOnDemand = false;
fAllowMultipleAddressesFromGroup = false;
fAllowMultiplePorts = false;
nLLMQConnectionRetryTimeout = 60;
nPoolMinParticipants = 3;
nPoolMaxParticipants = 5; // TODO: bump on next HF / mandatory upgrade
@ -571,6 +572,7 @@ public:
fMineBlocksOnDemand = false;
fAllowMultipleAddressesFromGroup = false;
fAllowMultiplePorts = true;
nLLMQConnectionRetryTimeout = 60;
nPoolMinParticipants = 3; // TODO drop to 2 with next mandatory upgrade
nPoolMaxParticipants = 5;
@ -727,6 +729,7 @@ public:
fMineBlocksOnDemand = false;
fAllowMultipleAddressesFromGroup = true;
fAllowMultiplePorts = true;
nLLMQConnectionRetryTimeout = 60;
nPoolMinParticipants = 3; // same, drop to 2 w/ breaking change
nPoolMaxParticipants = 5;
@ -837,6 +840,7 @@ public:
fMineBlocksOnDemand = true;
fAllowMultipleAddressesFromGroup = true;
fAllowMultiplePorts = true;
nLLMQConnectionRetryTimeout = 30; // must be lower then the LLMQ signing session timeout so that tests have control over failing behavior
nFulfilledRequestExpireTime = 5*60; // fulfilled requests expire in 5 minutes
nPoolMinParticipants = 2;

View File

@ -70,6 +70,8 @@ public:
bool AllowMultipleAddressesFromGroup() const { return fAllowMultipleAddressesFromGroup; }
/** Allow nodes with the same address and multiple ports */
bool AllowMultiplePorts() const { return fAllowMultiplePorts; }
/** How long to wait until we allow retrying of a LLMQ connection */
int LLMQConnectionRetryTimeout() const { return nLLMQConnectionRetryTimeout; }
/** Return the BIP70 network string (main, test or regtest) */
std::string NetworkIDString() const { return strNetworkID; }
/** Return the list of hostnames to look up for DNS seeds */
@ -112,6 +114,7 @@ protected:
bool fMineBlocksOnDemand;
bool fAllowMultipleAddressesFromGroup;
bool fAllowMultiplePorts;
int nLLMQConnectionRetryTimeout;
CCheckpointData checkpointData;
ChainTxData chainTxData;
int nPoolMinParticipants;

View File

@ -2103,6 +2103,8 @@ void CConnman::ThreadOpenMasternodeConnections()
if (gArgs.IsArgSet("-connect") && gArgs.GetArgs("-connect").size() > 0)
return;
auto& chainParams = Params();
while (!interruptNet)
{
if (!interruptNet.sleep_for(std::chrono::milliseconds(1000)))
@ -2152,7 +2154,7 @@ void CConnman::ThreadOpenMasternodeConnections()
if (!connectedNodes.count(addr2) && !IsMasternodeOrDisconnectRequested(addr2) && !connectedProRegTxHashes.count(proRegTxHash)) {
int64_t lastAttempt = mmetaman.GetMetaInfo(dmn->proTxHash)->GetLastOutboundAttempt();
// back off trying connecting to an address if we already tried recently
if (nANow - lastAttempt < 60) {
if (nANow - lastAttempt < chainParams.LLMQConnectionRetryTimeout()) {
continue;
}
pending.emplace_back(dmn);