diff --git a/src/darksend-relay.cpp b/src/darksend-relay.cpp index 07d258062..338e5fc18 100644 --- a/src/darksend-relay.cpp +++ b/src/darksend-relay.cpp @@ -99,12 +99,12 @@ void CDarkSendRelay::Relay() void CDarkSendRelay::RelayThroughNode(int nRank) { - CMasternode* pmn = mnodeman.GetMasternodeByRank(nRank, nBlockHeight, MIN_PRIVATESEND_PEER_PROTO_VERSION); + masternode_info_t mnInfo; - if(pmn != NULL){ - //printf("RelayThroughNode %s\n", pmn->addr.ToString().c_str()); + if(mnodeman.GetMasternodeByRank(nRank, nBlockHeight, MIN_PRIVATESEND_PEER_PROTO_VERSION, false, mnInfo)){ + //printf("RelayThroughNode %s\n", mnInfo.addr.ToString().c_str()); // TODO: Pass CConnman instance somehow and don't use global variable. - CNode* pnode = g_connman->ConnectNode((CAddress)pmn->addr, NULL); + CNode* pnode = g_connman->ConnectNode((CAddress)mnInfo.addr, NULL); if(pnode) { //printf("Connected\n"); pnode->PushMessage("dsr", (*this)); diff --git a/src/masternodeman.cpp b/src/masternodeman.cpp index c54f6c284..068a874e5 100644 --- a/src/masternodeman.cpp +++ b/src/masternodeman.cpp @@ -658,7 +658,7 @@ std::vector > CMasternodeMan::GetMasternodeRanks(int return vecMasternodeRanks; } -CMasternode* CMasternodeMan::GetMasternodeByRank(int nRank, int nBlockHeight, int nMinProtocol, bool fOnlyActive) +bool CMasternodeMan::GetMasternodeByRank(int nRank, int nBlockHeight, int nMinProtocol, bool fOnlyActive, masternode_info_t& mnInfoRet) { std::vector > vecMasternodeScores; @@ -667,7 +667,7 @@ CMasternode* CMasternodeMan::GetMasternodeByRank(int nRank, int nBlockHeight, in uint256 blockHash; if(!GetBlockHash(blockHash, nBlockHeight)) { LogPrintf("CMasternode::GetMasternodeByRank -- ERROR: GetBlockHash() failed at nBlockHeight %d\n", nBlockHeight); - return NULL; + return false; } // Fill scores @@ -687,11 +687,12 @@ CMasternode* CMasternodeMan::GetMasternodeByRank(int nRank, int nBlockHeight, in BOOST_FOREACH (PAIRTYPE(int64_t, CMasternode*)& s, vecMasternodeScores){ rank++; if(rank == nRank) { - return s.second; + mnInfoRet = *s.second; + return true; } } - return NULL; + return false; } void CMasternodeMan::ProcessMasternodeConnections() diff --git a/src/masternodeman.h b/src/masternodeman.h index c2c788637..b98886b0e 100644 --- a/src/masternodeman.h +++ b/src/masternodeman.h @@ -168,7 +168,7 @@ public: std::vector > GetMasternodeRanks(int nBlockHeight = -1, int nMinProtocol=0); int GetMasternodeRank(const CTxIn &vin, int nBlockHeight, int nMinProtocol=0, bool fOnlyActive=true); - CMasternode* GetMasternodeByRank(int nRank, int nBlockHeight, int nMinProtocol=0, bool fOnlyActive=true); + bool GetMasternodeByRank(int nRank, int nBlockHeight, int nMinProtocol, bool fOnlyActive, masternode_info_t& mnInfoRet); void ProcessMasternodeConnections(); std::pair > PopScheduledMnbRequestConnection();