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