better naming/readability (Find)

This commit is contained in:
UdjinM6 2015-02-25 14:54:03 +03:00
parent 259752c627
commit 0d51e1c90d
7 changed files with 73 additions and 73 deletions

View File

@ -201,10 +201,10 @@ bool CActiveMasternode::Dseep(CTxIn vin, CService service, CKey keyMasternode, C
} }
// Update Last Seen timestamp in masternode list // Update Last Seen timestamp in masternode list
CMasternode* mn = mnodeman.Find(vin); CMasternode* pmn = mnodeman.Find(vin);
if(mn) if(pmn != NULL)
{ {
mn->UpdateLastSeen(); pmn->UpdateLastSeen();
} }
else else
{ {
@ -267,8 +267,8 @@ bool CActiveMasternode::Register(CTxIn vin, CService service, CKey keyCollateral
return false; return false;
} }
CMasternode* mn = mnodeman.Find(vin); CMasternode* pmn = mnodeman.Find(vin);
if(!mn) if(pmn == NULL)
{ {
LogPrintf("CActiveMasternode::Register() - Adding to masternode list service: %s - vin: %s\n", service.ToString().c_str(), vin.ToString().c_str()); LogPrintf("CActiveMasternode::Register() - Adding to masternode list service: %s - vin: %s\n", service.ToString().c_str(), vin.ToString().c_str());
CMasternode mn(service, vin, pubKeyCollateralAddress, vchMasterNodeSignature, masterNodeSignatureTime, pubKeyMasternode, PROTOCOL_VERSION); CMasternode mn(service, vin, pubKeyCollateralAddress, vchMasterNodeSignature, masterNodeSignatureTime, pubKeyMasternode, PROTOCOL_VERSION);

View File

@ -121,8 +121,8 @@ void ProcessMessageDarksend(CNode* pfrom, std::string& strCommand, CDataStream&
vRecv >> nDenom >> txCollateral; vRecv >> nDenom >> txCollateral;
std::string error = ""; std::string error = "";
CMasternode* mn = mnodeman.Find(activeMasternode.vin); CMasternode* pmn = mnodeman.Find(activeMasternode.vin);
if(!mn) if(pmn == NULL)
{ {
std::string strError = _("Not in the masternode list."); std::string strError = _("Not in the masternode list.");
pfrom->PushMessage("dssu", darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), MASTERNODE_REJECTED, strError); pfrom->PushMessage("dssu", darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), MASTERNODE_REJECTED, strError);
@ -130,9 +130,9 @@ void ProcessMessageDarksend(CNode* pfrom, std::string& strCommand, CDataStream&
} }
if(darkSendPool.sessionUsers == 0) { if(darkSendPool.sessionUsers == 0) {
if(mn->nLastDsq != 0 && if(pmn->nLastDsq != 0 &&
mn->nLastDsq + mnodeman.CountMasternodesAboveProtocol(darkSendPool.MIN_PEER_PROTO_VERSION)/5 > darkSendPool.nDsqCount){ pmn->nLastDsq + mnodeman.CountMasternodesAboveProtocol(darkSendPool.MIN_PEER_PROTO_VERSION)/5 > darkSendPool.nDsqCount){
LogPrintf("dsa -- last dsq too recent, must wait. %s \n", mn->addr.ToString().c_str()); LogPrintf("dsa -- last dsq too recent, must wait. %s \n", pmn->addr.ToString().c_str());
std::string strError = _("Last Darksend was too recent."); std::string strError = _("Last Darksend was too recent.");
pfrom->PushMessage("dssu", darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), MASTERNODE_REJECTED, strError); pfrom->PushMessage("dssu", darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), MASTERNODE_REJECTED, strError);
return; return;
@ -165,8 +165,8 @@ void ProcessMessageDarksend(CNode* pfrom, std::string& strCommand, CDataStream&
if(dsq.IsExpired()) return; if(dsq.IsExpired()) return;
CMasternode* mn = mnodeman.Find(dsq.vin); CMasternode* pmn = mnodeman.Find(dsq.vin);
if(!mn) return; if(pmn == NULL) return;
// if the queue is ready, submit if we can // if the queue is ready, submit if we can
if(dsq.ready) { if(dsq.ready) {
@ -182,16 +182,16 @@ void ProcessMessageDarksend(CNode* pfrom, std::string& strCommand, CDataStream&
if(q.vin == dsq.vin) return; if(q.vin == dsq.vin) return;
} }
if(fDebug) LogPrintf("dsq last %d last2 %d count %d\n", mn->nLastDsq, mn->nLastDsq + mnodeman.size()/5, darkSendPool.nDsqCount); if(fDebug) LogPrintf("dsq last %d last2 %d count %d\n", pmn->nLastDsq, pmn->nLastDsq + mnodeman.size()/5, darkSendPool.nDsqCount);
//don't allow a few nodes to dominate the queuing process //don't allow a few nodes to dominate the queuing process
if(mn->nLastDsq != 0 && if(pmn->nLastDsq != 0 &&
mn->nLastDsq + mnodeman.CountMasternodesAboveProtocol(darkSendPool.MIN_PEER_PROTO_VERSION)/5 > darkSendPool.nDsqCount){ pmn->nLastDsq + mnodeman.CountMasternodesAboveProtocol(darkSendPool.MIN_PEER_PROTO_VERSION)/5 > darkSendPool.nDsqCount){
if(fDebug) LogPrintf("dsq -- masternode sending too many dsq messages. %s \n", mn->addr.ToString().c_str()); if(fDebug) LogPrintf("dsq -- masternode sending too many dsq messages. %s \n", pmn->addr.ToString().c_str());
return; return;
} }
darkSendPool.nDsqCount++; darkSendPool.nDsqCount++;
mn->nLastDsq = darkSendPool.nDsqCount; pmn->nLastDsq = darkSendPool.nDsqCount;
mn->allowFreeTx = true; pmn->allowFreeTx = true;
if(fDebug) LogPrintf("dsq - new darksend queue object - %s\n", addr.ToString().c_str()); if(fDebug) LogPrintf("dsq - new darksend queue object - %s\n", addr.ToString().c_str());
vecDarksendQueue.push_back(dsq); vecDarksendQueue.push_back(dsq);
@ -2131,14 +2131,14 @@ bool CDarksendQueue::Relay()
bool CDarksendQueue::CheckSignature() bool CDarksendQueue::CheckSignature()
{ {
CMasternode* mn = mnodeman.Find(vin); CMasternode* pmn = mnodeman.Find(vin);
if(mn) if(pmn != NULL)
{ {
std::string strMessage = vin.ToString() + boost::lexical_cast<std::string>(nDenom) + boost::lexical_cast<std::string>(time) + boost::lexical_cast<std::string>(ready); std::string strMessage = vin.ToString() + boost::lexical_cast<std::string>(nDenom) + boost::lexical_cast<std::string>(time) + boost::lexical_cast<std::string>(ready);
std::string errorMessage = ""; std::string errorMessage = "";
if(!darkSendSigner.VerifyMessage(mn->pubkey2, vchSig, strMessage, errorMessage)){ if(!darkSendSigner.VerifyMessage(pmn->pubkey2, vchSig, strMessage, errorMessage)){
return error("CDarksendQueue::CheckSignature() - Got bad masternode address signature %s \n", vin.ToString().c_str()); return error("CDarksendQueue::CheckSignature() - Got bad masternode address signature %s \n", vin.ToString().c_str());
} }

View File

@ -157,10 +157,10 @@ public:
bool GetAddress(CService &addr) bool GetAddress(CService &addr)
{ {
CMasternode* mn = mnodeman.Find(vin); CMasternode* pmn = mnodeman.Find(vin);
if(mn) if(pmn != NULL)
{ {
addr = mn->addr; addr = pmn->addr;
return true; return true;
} }
return false; return false;
@ -168,10 +168,10 @@ public:
bool GetProtocolVersion(int &protocolVersion) bool GetProtocolVersion(int &protocolVersion)
{ {
CMasternode* mn = mnodeman.Find(vin); CMasternode* pmn = mnodeman.Find(vin);
if(mn) if(pmn != NULL)
{ {
protocolVersion = mn->protocolVersion; protocolVersion = pmn->protocolVersion;
return true; return true;
} }
return false; return false;

View File

@ -309,10 +309,10 @@ bool ProcessConsensusVote(CConsensusVote& ctx)
{ {
int n = mnodeman.GetMasternodeRank(ctx.vinMasternode, ctx.nBlockHeight, MIN_INSTANTX_PROTO_VERSION); int n = mnodeman.GetMasternodeRank(ctx.vinMasternode, ctx.nBlockHeight, MIN_INSTANTX_PROTO_VERSION);
CMasternode* mn = mnodeman.Find(ctx.vinMasternode); CMasternode* pmn = mnodeman.Find(ctx.vinMasternode);
if(mn) if(pmn != NULL)
{ {
if(fDebug) LogPrintf("InstantX::ProcessConsensusVote - Masternode ADDR %s %d\n", mn->addr.ToString().c_str(), n); if(fDebug) LogPrintf("InstantX::ProcessConsensusVote - Masternode ADDR %s %d\n", pmn->addr.ToString().c_str(), n);
} }
if(n == -1) if(n == -1)
@ -481,9 +481,9 @@ bool CConsensusVote::SignatureValid()
std::string strMessage = txHash.ToString().c_str() + boost::lexical_cast<std::string>(nBlockHeight); std::string strMessage = txHash.ToString().c_str() + boost::lexical_cast<std::string>(nBlockHeight);
//LogPrintf("verify strMessage %s \n", strMessage.c_str()); //LogPrintf("verify strMessage %s \n", strMessage.c_str());
CMasternode* mn = mnodeman.Find(vinMasternode); CMasternode* pmn = mnodeman.Find(vinMasternode);
if(!mn) if(pmn == NULL)
{ {
LogPrintf("InstantX::CConsensusVote::SignatureValid() - Unknown Masternode\n"); LogPrintf("InstantX::CConsensusVote::SignatureValid() - Unknown Masternode\n");
return false; return false;
@ -494,13 +494,13 @@ bool CConsensusVote::SignatureValid()
//LogPrintf("verify addr %d %s \n", n, vecMasternodes[n].addr.ToString().c_str()); //LogPrintf("verify addr %d %s \n", n, vecMasternodes[n].addr.ToString().c_str());
CScript pubkey; CScript pubkey;
pubkey.SetDestination(mn->pubkey2.GetID()); pubkey.SetDestination(pmn->pubkey2.GetID());
CTxDestination address1; CTxDestination address1;
ExtractDestination(pubkey, address1); ExtractDestination(pubkey, address1);
CBitcoinAddress address2(address1); CBitcoinAddress address2(address1);
//LogPrintf("verify pubkey2 %s \n", address2.ToString().c_str()); //LogPrintf("verify pubkey2 %s \n", address2.ToString().c_str());
if(!darkSendSigner.VerifyMessage(mn->pubkey2, vchMasterNodeSignature, strMessage, errorMessage)) { if(!darkSendSigner.VerifyMessage(pmn->pubkey2, vchMasterNodeSignature, strMessage, errorMessage)) {
LogPrintf("InstantX::CConsensusVote::SignatureValid() - Verify message failed\n"); LogPrintf("InstantX::CConsensusVote::SignatureValid() - Verify message failed\n");
return false; return false;
} }

View File

@ -4457,10 +4457,10 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
//these allow masternodes to publish a limited amount of free transactions //these allow masternodes to publish a limited amount of free transactions
vRecv >> tx >> vin >> vchSig >> sigTime; vRecv >> tx >> vin >> vchSig >> sigTime;
CMasternode* mn = mnodeman.Find(vin); CMasternode* pmn = mnodeman.Find(vin);
if(mn) if(pmn != NULL)
{ {
if(!mn->allowFreeTx){ if(!pmn->allowFreeTx){
//multiple peers can send us a valid masternode transaction //multiple peers can send us a valid masternode transaction
if(fDebug) LogPrintf("dstx: Masternode sending too many transactions %s\n", tx.GetHash().ToString().c_str()); if(fDebug) LogPrintf("dstx: Masternode sending too many transactions %s\n", tx.GetHash().ToString().c_str());
return true; return true;
@ -4469,7 +4469,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
std::string strMessage = tx.GetHash().ToString() + boost::lexical_cast<std::string>(sigTime); std::string strMessage = tx.GetHash().ToString() + boost::lexical_cast<std::string>(sigTime);
std::string errorMessage = ""; std::string errorMessage = "";
if(!darkSendSigner.VerifyMessage(mn->pubkey2, vchSig, strMessage, errorMessage)){ if(!darkSendSigner.VerifyMessage(pmn->pubkey2, vchSig, strMessage, errorMessage)){
LogPrintf("dstx: Got bad masternode address signature %s \n", vin.ToString().c_str()); LogPrintf("dstx: Got bad masternode address signature %s \n", vin.ToString().c_str());
//pfrom->Misbehaving(20); //pfrom->Misbehaving(20);
return false; return false;
@ -4478,7 +4478,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
LogPrintf("dstx: Got Masternode transaction %s\n", tx.GetHash().ToString().c_str()); LogPrintf("dstx: Got Masternode transaction %s\n", tx.GetHash().ToString().c_str());
allowFree = true; allowFree = true;
mn->allowFreeTx = false; pmn->allowFreeTx = false;
if(!mapDarksendBroadcastTxes.count(tx.GetHash())){ if(!mapDarksendBroadcastTxes.count(tx.GetHash())){
CDarksendBroadcastTx dstx; CDarksendBroadcastTx dstx;

View File

@ -381,13 +381,13 @@ bool CMasternodePayments::ProcessBlock(int nBlockHeight)
vecLastPayments.push_back(winner.vin); vecLastPayments.push_back(winner.vin);
} }
CMasternode* mn = mnodeman.FindNotInVec(vecLastPayments); CMasternode *pmn = mnodeman.FindNotInVec(vecLastPayments);
if(mn) if(pmn != NULL)
{ {
newWinner.score = 0; newWinner.score = 0;
newWinner.nBlockHeight = nBlockHeight; newWinner.nBlockHeight = nBlockHeight;
newWinner.vin = mn->vin; newWinner.vin = pmn->vin;
newWinner.payee.SetDestination(mn->pubkey.GetID()); newWinner.payee.SetDestination(pmn->pubkey.GetID());
} }
//if we can't find new MN to get paid, pick first active MN counting back from the end of vecLastPayments list //if we can't find new MN to get paid, pick first active MN counting back from the end of vecLastPayments list
@ -395,16 +395,16 @@ bool CMasternodePayments::ProcessBlock(int nBlockHeight)
{ {
BOOST_REVERSE_FOREACH(CTxIn& vinLP, vecLastPayments) BOOST_REVERSE_FOREACH(CTxIn& vinLP, vecLastPayments)
{ {
CMasternode* mn = mnodeman.Find(vinLP); CMasternode* pmn = mnodeman.Find(vinLP);
if(mn) if(pmn != NULL)
{ {
mn->Check(); pmn->Check();
if(!mn->IsEnabled()) continue; if(!pmn->IsEnabled()) continue;
newWinner.score = 0; newWinner.score = 0;
newWinner.nBlockHeight = nBlockHeight; newWinner.nBlockHeight = nBlockHeight;
newWinner.vin = mn->vin; newWinner.vin = pmn->vin;
newWinner.payee.SetDestination(mn->pubkey.GetID()); newWinner.payee.SetDestination(pmn->pubkey.GetID());
break; // we found active MN break; // we found active MN
} }
} }

View File

@ -190,7 +190,7 @@ bool CMasternodeMan::Add(CMasternode &mn)
CMasternode *pmn = Find(mn.vin); CMasternode *pmn = Find(mn.vin);
if (!pmn) if (pmn == NULL)
{ {
vMasternodes.push_back(mn); vMasternodes.push_back(mn);
UpdateLastTimeChanged(); UpdateLastTimeChanged();
@ -390,26 +390,26 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
} }
//search existing masternode list, this is where we update existing masternodes with new dsee broadcasts //search existing masternode list, this is where we update existing masternodes with new dsee broadcasts
CMasternode* mn = this->Find(vin); CMasternode* pmn = this->Find(vin);
if(mn) if(pmn != NULL)
{ {
// count == -1 when it's a new entry // count == -1 when it's a new entry
// e.g. We don't want the entry relayed/time updated when we're syncing the list // e.g. We don't want the entry relayed/time updated when we're syncing the list
// mn.pubkey = pubkey, IsVinAssociatedWithPubkey is validated once below, // mn.pubkey = pubkey, IsVinAssociatedWithPubkey is validated once below,
// after that they just need to match // after that they just need to match
if(count == -1 && mn->pubkey == pubkey && !mn->UpdatedWithin(MASTERNODE_MIN_DSEE_SECONDS)){ if(count == -1 && pmn->pubkey == pubkey && !pmn->UpdatedWithin(MASTERNODE_MIN_DSEE_SECONDS)){
mn->UpdateLastSeen(); pmn->UpdateLastSeen();
UpdateLastTimeChanged(); UpdateLastTimeChanged();
if(mn->now < sigTime){ //take the newest entry if(pmn->now < sigTime){ //take the newest entry
LogPrintf("dsee - Got updated entry for %s\n", addr.ToString().c_str()); LogPrintf("dsee - Got updated entry for %s\n", addr.ToString().c_str());
mn->pubkey2 = pubkey2; pmn->pubkey2 = pubkey2;
mn->now = sigTime; pmn->now = sigTime;
mn->sig = vchSig; pmn->sig = vchSig;
mn->protocolVersion = protocolVersion; pmn->protocolVersion = protocolVersion;
mn->addr = addr; pmn->addr = addr;
mn->Check(); pmn->Check();
if(mn->IsEnabled()) if(pmn->IsEnabled())
RelayDarkSendElectionEntry(vin, addr, vchSig, sigTime, pubkey, pubkey2, count, current, lastUpdated, protocolVersion); RelayDarkSendElectionEntry(vin, addr, vchSig, sigTime, pubkey, pubkey2, count, current, lastUpdated, protocolVersion);
} }
} }
@ -495,34 +495,34 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
} }
// see if we have this masternode // see if we have this masternode
CMasternode* mn = this->Find(vin); CMasternode* pmn = this->Find(vin);
if(mn) if(pmn != NULL)
{ {
// LogPrintf("dseep - Found corresponding mn for vin: %s\n", vin.ToString().c_str()); // LogPrintf("dseep - Found corresponding mn for vin: %s\n", vin.ToString().c_str());
// take this only if it's newer // take this only if it's newer
if(mn->lastDseep < sigTime) if(pmn->lastDseep < sigTime)
{ {
std::string strMessage = mn->addr.ToString() + boost::lexical_cast<std::string>(sigTime) + boost::lexical_cast<std::string>(stop); std::string strMessage = pmn->addr.ToString() + boost::lexical_cast<std::string>(sigTime) + boost::lexical_cast<std::string>(stop);
std::string errorMessage = ""; std::string errorMessage = "";
if(!darkSendSigner.VerifyMessage(mn->pubkey2, vchSig, strMessage, errorMessage)) if(!darkSendSigner.VerifyMessage(pmn->pubkey2, vchSig, strMessage, errorMessage))
{ {
LogPrintf("dseep - Got bad masternode address signature %s \n", vin.ToString().c_str()); LogPrintf("dseep - Got bad masternode address signature %s \n", vin.ToString().c_str());
//Misbehaving(pfrom->GetId(), 100); //Misbehaving(pfrom->GetId(), 100);
return; return;
} }
mn->lastDseep = sigTime; pmn->lastDseep = sigTime;
if(!mn->UpdatedWithin(MASTERNODE_MIN_DSEEP_SECONDS)) if(!pmn->UpdatedWithin(MASTERNODE_MIN_DSEEP_SECONDS))
{ {
UpdateLastTimeChanged(); UpdateLastTimeChanged();
if(stop) mn->Disable(); if(stop) pmn->Disable();
else else
{ {
mn->UpdateLastSeen(); pmn->UpdateLastSeen();
mn->Check(); pmn->Check();
if(!mn->IsEnabled()) return; if(!pmn->IsEnabled()) return;
} }
RelayDarkSendElectionEntryPing(vin, vchSig, sigTime, stop); RelayDarkSendElectionEntryPing(vin, vchSig, sigTime, stop);
} }