mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 04:22:55 +01:00
Make pending masternode queue proTxHash based
Instead of CService
This commit is contained in:
parent
0adef2cf7a
commit
35d75b19e6
31
src/net.cpp
31
src/net.cpp
@ -2126,20 +2126,20 @@ void CConnman::ThreadOpenMasternodeConnections()
|
||||
|
||||
// NOTE: Process only one pending masternode at a time
|
||||
|
||||
CService addr;
|
||||
CDeterministicMNCPtr connectToDmn;
|
||||
{ // don't hold lock while calling OpenMasternodeConnection as cs_main is locked deep inside
|
||||
LOCK2(cs_vNodes, cs_vPendingMasternodes);
|
||||
|
||||
if (!vPendingMasternodes.empty()) {
|
||||
auto addr2 = vPendingMasternodes.front();
|
||||
auto dmn = mnList.GetValidMN(vPendingMasternodes.front());
|
||||
vPendingMasternodes.erase(vPendingMasternodes.begin());
|
||||
if (!connectedNodes.count(addr2) && !IsMasternodeOrDisconnectRequested(addr2)) {
|
||||
addr = addr2;
|
||||
if (dmn && !connectedNodes.count(dmn->pdmnState->addr) && !IsMasternodeOrDisconnectRequested(dmn->pdmnState->addr)) {
|
||||
connectToDmn = dmn;
|
||||
}
|
||||
}
|
||||
|
||||
if (addr == CService()) {
|
||||
std::vector<CService> pending;
|
||||
if (!connectToDmn) {
|
||||
std::vector<CDeterministicMNCPtr> pending;
|
||||
for (const auto& group : masternodeQuorumNodes) {
|
||||
for (const auto& proRegTxHash : group.second) {
|
||||
auto dmn = mnList.GetMN(proRegTxHash);
|
||||
@ -2153,24 +2153,24 @@ void CConnman::ThreadOpenMasternodeConnections()
|
||||
if (addrInfo.IsValid() && nANow - addrInfo.nLastTry < 60) {
|
||||
continue;
|
||||
}
|
||||
pending.emplace_back(addr2);
|
||||
pending.emplace_back(dmn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!pending.empty()) {
|
||||
addr = pending[GetRandInt(pending.size())];
|
||||
connectToDmn = pending[GetRandInt(pending.size())];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (addr == CService()) {
|
||||
if (!connectToDmn) {
|
||||
continue;
|
||||
}
|
||||
|
||||
OpenMasternodeConnection(CAddress(addr, NODE_NETWORK));
|
||||
OpenMasternodeConnection(CAddress(connectToDmn->pdmnState->addr, NODE_NETWORK));
|
||||
// should be in the list now if connection was opened
|
||||
ForNode(addr, CConnman::AllNodes, [&](CNode* pnode) {
|
||||
ForNode(connectToDmn->pdmnState->addr, CConnman::AllNodes, [&](CNode* pnode) {
|
||||
if (pnode->fDisconnect) {
|
||||
return false;
|
||||
}
|
||||
@ -2782,15 +2782,14 @@ bool CConnman::RemoveAddedNode(const std::string& strNode)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CConnman::AddPendingMasternode(const CService& service)
|
||||
bool CConnman::AddPendingMasternode(const uint256& proTxHash)
|
||||
{
|
||||
LOCK(cs_vPendingMasternodes);
|
||||
for(const auto& s : vPendingMasternodes) {
|
||||
if (service == s)
|
||||
return false;
|
||||
if (std::find(vPendingMasternodes.begin(), vPendingMasternodes.end(), proTxHash) != vPendingMasternodes.end()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
vPendingMasternodes.push_back(service);
|
||||
vPendingMasternodes.push_back(proTxHash);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -407,7 +407,7 @@ public:
|
||||
bool RemoveAddedNode(const std::string& node);
|
||||
std::vector<AddedNodeInfo> GetAddedNodeInfo();
|
||||
|
||||
bool AddPendingMasternode(const CService& addr);
|
||||
bool AddPendingMasternode(const uint256& proTxHash);
|
||||
bool AddMasternodeQuorumNodes(Consensus::LLMQType llmqType, const uint256& quorumHash, const std::set<uint256>& proTxHashes);
|
||||
bool HasMasternodeQuorumNodes(Consensus::LLMQType llmqType, const uint256& quorumHash);
|
||||
std::set<uint256> GetMasternodeQuorums(Consensus::LLMQType llmqType);
|
||||
@ -543,7 +543,7 @@ private:
|
||||
CCriticalSection cs_vOneShots;
|
||||
std::vector<std::string> vAddedNodes GUARDED_BY(cs_vAddedNodes);
|
||||
CCriticalSection cs_vAddedNodes;
|
||||
std::vector<CService> vPendingMasternodes;
|
||||
std::vector<uint256> vPendingMasternodes;
|
||||
std::map<std::pair<Consensus::LLMQType, uint256>, std::set<uint256>> masternodeQuorumNodes; // protected by cs_vPendingMasternodes
|
||||
mutable CCriticalSection cs_vPendingMasternodes;
|
||||
std::vector<CNode*> vNodes;
|
||||
|
@ -1081,7 +1081,7 @@ bool CPrivateSendClientSession::JoinExistingQueue(CAmount nBalanceNeedsAnonymize
|
||||
nSessionDenom = dsq.nDenom;
|
||||
mixingMasternode = dmn;
|
||||
pendingDsaRequest = CPendingDsaRequest(dmn->pdmnState->addr, CPrivateSendAccept(nSessionDenom, txMyCollateral));
|
||||
connman.AddPendingMasternode(dmn->pdmnState->addr);
|
||||
connman.AddPendingMasternode(dmn->proTxHash);
|
||||
// TODO: add new state POOL_STATE_CONNECTING and bump MIN_PRIVATESEND_PEER_PROTO_VERSION
|
||||
SetState(POOL_STATE_QUEUE);
|
||||
nTimeLastSuccessfulStep = GetTime();
|
||||
@ -1158,7 +1158,7 @@ bool CPrivateSendClientSession::StartNewQueue(CAmount nBalanceNeedsAnonymized, C
|
||||
}
|
||||
|
||||
mixingMasternode = dmn;
|
||||
connman.AddPendingMasternode(dmn->pdmnState->addr);
|
||||
connman.AddPendingMasternode(dmn->proTxHash);
|
||||
pendingDsaRequest = CPendingDsaRequest(dmn->pdmnState->addr, CPrivateSendAccept(nSessionDenom, txMyCollateral));
|
||||
// TODO: add new state POOL_STATE_CONNECTING and bump MIN_PRIVATESEND_PEER_PROTO_VERSION
|
||||
SetState(POOL_STATE_QUEUE);
|
||||
|
Loading…
Reference in New Issue
Block a user