safe version of GetMasternodeByRank (#1595)
* safe version of GetMasternodeByRank * fix
This commit is contained in:
parent
76181f5757
commit
9028a22b88
@ -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));
|
||||
|
@ -658,7 +658,7 @@ std::vector<std::pair<int, CMasternode> > 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<std::pair<int64_t, CMasternode*> > 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()
|
||||
|
@ -168,7 +168,7 @@ public:
|
||||
|
||||
std::vector<std::pair<int, CMasternode> > 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<CService, std::set<uint256> > PopScheduledMnbRequestConnection();
|
||||
|
Loading…
Reference in New Issue
Block a user