Stop banning nodes for unknown masternodes while processing budget messages.

Also cleanup naming/logging a bit.
This commit is contained in:
UdjinM6 2015-07-07 00:00:00 +03:00
parent 05e126f853
commit e40de28900

View File

@ -810,7 +810,7 @@ void CBudgetManager::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
pfrom->FulfilledRequest("mnvs"); pfrom->FulfilledRequest("mnvs");
budget.Sync(pfrom, nProp); budget.Sync(pfrom, nProp);
LogPrintf("mnvs - Sent Masternode votes to %s\n", pfrom->addr.ToString().c_str()); LogPrintf("mnvs - Sent Masternode votes to %s\n", pfrom->addr.ToString());
} }
if (strCommand == "mprop") { //Masternode Proposal if (strCommand == "mprop") { //Masternode Proposal
@ -827,6 +827,12 @@ void CBudgetManager::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
//set time we first saw this prop //set time we first saw this prop
prop.nTime = GetAdjustedTime(); prop.nTime = GetAdjustedTime();
CMasternode* pmn = mnodeman.Find(prop.vin);
if(pmn == NULL) {
if(fDebug) LogPrintf("mprop - unknown masternode - vin: %s\n", prop.vin.ToString());
return;
}
if(!prop.SignatureValid()){ if(!prop.SignatureValid()){
LogPrintf("mprop - signature invalid\n"); LogPrintf("mprop - signature invalid\n");
Misbehaving(pfrom->GetId(), 20); Misbehaving(pfrom->GetId(), 20);
@ -835,13 +841,7 @@ void CBudgetManager::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
std::string strError = ""; std::string strError = "";
if(!prop.IsValid(strError)) { if(!prop.IsValid(strError)) {
LogPrintf("mprop - invalid prop - %s\n", strError.c_str()); LogPrintf("mprop - invalid budget proposal - %s\n", strError.c_str());
return;
}
CMasternode* pmn = mnodeman.Find(prop.vin);
if(pmn == NULL) {
LogPrintf("mprop - unknown masternode - vin:%s \n", pmn->vin.ToString().c_str());
return; return;
} }
@ -860,7 +860,7 @@ void CBudgetManager::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
//We might have active votes for this proposal that are valid now //We might have active votes for this proposal that are valid now
CheckOrphanVotes(); CheckOrphanVotes();
} else { } else {
LogPrintf("mvote - masternode can't vote again - vin:%s \n", pmn->vin.ToString().c_str()); LogPrintf("mvote - masternode can't vote again - vin: %s\n", pmn->vin.ToString());
return; return;
} }
} }
@ -873,15 +873,15 @@ void CBudgetManager::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
return; return;
} }
if(!vote.SignatureValid()){ CMasternode* pmn = mnodeman.Find(vote.vin);
LogPrintf("mvote - signature invalid\n"); if(pmn == NULL) {
Misbehaving(pfrom->GetId(), 20); if(fDebug) LogPrintf("mvote - unknown masternode - vin: %s\n", vote.vin.ToString());
return; return;
} }
CMasternode* pmn = mnodeman.Find(vote.vin); if(!vote.SignatureValid()){
if(pmn == NULL) { LogPrintf("mvote - signature invalid\n");
LogPrintf("mvote - unknown masternode - vin:%s \n", pmn->vin.ToString().c_str()); Misbehaving(pfrom->GetId(), 20);
return; return;
} }
@ -891,54 +891,54 @@ void CBudgetManager::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
vote.Relay(); vote.Relay();
if(!IsSyncingMasternodeAssets()) pmn->nVotedTimes++; if(!IsSyncingMasternodeAssets()) pmn->nVotedTimes++;
} else { } else {
LogPrintf("mvote - masternode can't vote again - vin:%s \n", pmn->vin.ToString().c_str()); LogPrintf("mvote - masternode can't vote again - vin: %s\n", pmn->vin.ToString());
return; return;
} }
} }
if (strCommand == "fbs") { //Finalized Budget Suggestion if (strCommand == "fbs") { //Finalized Budget Suggestion
CFinalizedBudgetBroadcast prop; CFinalizedBudgetBroadcast fbs;
vRecv >> prop; vRecv >> fbs;
if(mapSeenFinalizedBudgets.count(prop.GetHash())){ if(mapSeenFinalizedBudgets.count(fbs.GetHash())){
//if this budget went inactive, we'll update it with the new re-signature //if this budget went inactive, we'll update it with the new re-signature
if(!mapSeenFinalizedBudgets[prop.GetHash()].fInvalid){ if(!mapSeenFinalizedBudgets[fbs.GetHash()].fInvalid){
return; return;
} }
} }
if(!prop.SignatureValid()){ CMasternode* pmn = mnodeman.Find(fbs.vin);
if(pmn == NULL) {
if(fDebug) LogPrintf("fbs - unknown masternode - vin: %s\n", fbs.vin.ToString());
return;
}
if(!fbs.SignatureValid()){
LogPrintf("fbs - signature invalid\n"); LogPrintf("fbs - signature invalid\n");
Misbehaving(pfrom->GetId(), 20); Misbehaving(pfrom->GetId(), 20);
return; return;
} }
if(!prop.IsValid()) { if(!fbs.IsValid()) {
LogPrintf("fbs - invalid prop\n"); LogPrintf("fbs - invalid finalized budget\n");
return;
}
CMasternode* pmn = mnodeman.Find(prop.vin);
if(pmn == NULL) {
LogPrintf("fbs - unknown masternode - vin:%s \n", pmn->vin.ToString().c_str());
return; return;
} }
//delete if it exists and insert the new object //delete if it exists and insert the new object
if(mapSeenFinalizedBudgets.count(prop.GetHash())) mapSeenFinalizedBudgets.erase(prop.GetHash()); if(mapSeenFinalizedBudgets.count(fbs.GetHash())) mapSeenFinalizedBudgets.erase(fbs.GetHash());
mapSeenFinalizedBudgets.insert(make_pair(prop.GetHash(), prop)); mapSeenFinalizedBudgets.insert(make_pair(fbs.GetHash(), fbs));
if(IsSyncingMasternodeAssets() || pmn->nVotedTimes < 100){ if(IsSyncingMasternodeAssets() || pmn->nVotedTimes < 100){
CFinalizedBudget p(prop); CFinalizedBudget p(fbs);
budget.AddFinalizedBudget(p); budget.AddFinalizedBudget(p);
prop.Relay(); fbs.Relay();
if(!IsSyncingMasternodeAssets()) pmn->nVotedTimes+=VOTE_PROP_INC; if(!IsSyncingMasternodeAssets()) pmn->nVotedTimes+=VOTE_PROP_INC;
//we might have active votes for this budget that are now valid //we might have active votes for this budget that are now valid
CheckOrphanVotes(); CheckOrphanVotes();
} else { } else {
LogPrintf("fbs - masternode can't vote again - vin:%s \n", pmn->vin.ToString().c_str()); LogPrintf("fbs - masternode can't vote again - vin: %s\n", pmn->vin.ToString());
return; return;
} }
} }
@ -951,15 +951,15 @@ void CBudgetManager::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
return; return;
} }
if(!vote.SignatureValid()){ CMasternode* pmn = mnodeman.Find(vote.vin);
LogPrintf("fbvote - signature invalid\n"); if(pmn == NULL) {
Misbehaving(pfrom->GetId(), 20); if(fDebug) LogPrintf("fbvote - unknown masternode - vin: %s\n", vote.vin.ToString());
return; return;
} }
CMasternode* pmn = mnodeman.Find(vote.vin); if(!vote.SignatureValid()){
if(pmn == NULL) { LogPrintf("fbvote - signature invalid\n");
LogPrintf("fbvote - unknown masternode - vin:%s \n", pmn->vin.ToString().c_str()); Misbehaving(pfrom->GetId(), 20);
return; return;
} }
@ -969,7 +969,7 @@ void CBudgetManager::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
vote.Relay(); vote.Relay();
if(!IsSyncingMasternodeAssets()) pmn->nVotedTimes++; if(!IsSyncingMasternodeAssets()) pmn->nVotedTimes++;
} else { } else {
LogPrintf("fbvote - masternode can't vote again - vin:%s \n", pmn->vin.ToString().c_str()); LogPrintf("fbvote - masternode can't vote again - vin: %s\n", pmn->vin.ToString());
return; return;
} }
} }
@ -1400,7 +1400,7 @@ bool CBudgetVote::SignatureValid()
if(pmn == NULL) if(pmn == NULL)
{ {
LogPrintf("CBudgetProposalBroadcast::SignatureValid() - Unknown Masternode - %s\n", vin.ToString().c_str()); LogPrintf("CBudgetVote::SignatureValid() - Unknown Masternode - %s\n", vin.ToString().c_str());
return false; return false;
} }