From 31370decd7efcda258a1fd2ecd81f9ad0a121de5 Mon Sep 17 00:00:00 2001 From: Tim Flynn Date: Mon, 14 Nov 2016 15:26:53 -0500 Subject: [PATCH] Changed log message handling due to code review suggestion --- src/governance.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/governance.cpp b/src/governance.cpp index 6a3aefe76..b6aeb48c2 100644 --- a/src/governance.cpp +++ b/src/governance.cpp @@ -618,14 +618,17 @@ bool CGovernanceManager::ProcessVote(CNode* pfrom, const CGovernanceVote& vote, uint256 nHashGovobj = vote.GetParentHash(); object_m_it it = mapObjects.find(nHashGovobj); if(it == mapObjects.end()) { + std::ostringstream ostr; + ostr << "CGovernanceManager::ProcessVote -- Unknown parent object " + << ", MN outpoint = " << vote.GetVinMasternode().prevout.ToStringShort() + << ", governance object hash = " << vote.GetParentHash().ToString() << "\n"; + exception = CGovernanceException(ostr.str(), GOVERNANCE_EXCEPTION_WARNING); if(mapOrphanVotes.Insert(nHashGovobj, vote)) { RequestGovernanceObject(pfrom, nHashGovobj); - std::ostringstream ostr; - ostr << "CGovernanceManager::ProcessVote -- Unknown parent object " - << ", MN outpoint = " << vote.GetVinMasternode().prevout.ToStringShort() - << ", governance object hash = " << vote.GetParentHash().ToString() << "\n"; LogPrintf(ostr.str().c_str()); - exception = CGovernanceException(ostr.str(), GOVERNANCE_EXCEPTION_WARNING); + } + else { + LogPrint("gobject", ostr.str().c_str()); } return false; } @@ -815,14 +818,17 @@ bool CGovernanceObject::ProcessVote(CNode* pfrom, { int nMNIndex = governance.GetMasternodeIndex(vote.GetVinMasternode()); if(nMNIndex < 0) { + std::ostringstream ostr; + ostr << "CGovernanceObject::UpdateVote -- Masternode index not found\n"; + exception = CGovernanceException(ostr.str(), GOVERNANCE_EXCEPTION_WARNING); if(mapOrphanVotes.Insert(vote.GetVinMasternode(), vote)) { if(pfrom) { mnodeman.AskForMN(pfrom, vote.GetVinMasternode()); } - std::ostringstream ostr; - ostr << "CGovernanceObject::UpdateVote -- Masternode index not found\n"; LogPrintf(ostr.str().c_str()); - exception = CGovernanceException(ostr.str(), GOVERNANCE_EXCEPTION_WARNING); + } + else { + LogPrint("gobject", ostr.str().c_str()); } return false; }