remove unused pindex from IsValidLocally, fix cs_main in rpc (#1243)
This commit is contained in:
parent
8d7866cf6b
commit
ba8d8ae027
@ -404,27 +404,23 @@ std::string CGovernanceObject::GetDataAsString()
|
||||
return s;
|
||||
}
|
||||
|
||||
void CGovernanceObject::UpdateLocalValidity(const CBlockIndex *pCurrentBlockIndex)
|
||||
void CGovernanceObject::UpdateLocalValidity()
|
||||
{
|
||||
// THIS DOES NOT CHECK COLLATERAL, THIS IS CHECKED UPON ORIGINAL ARRIVAL
|
||||
fCachedLocalValidity = IsValidLocally(pCurrentBlockIndex, strLocalValidityError, false);
|
||||
fCachedLocalValidity = IsValidLocally(strLocalValidityError, false);
|
||||
};
|
||||
|
||||
|
||||
bool CGovernanceObject::IsValidLocally(const CBlockIndex* pindex, std::string& strError, bool fCheckCollateral)
|
||||
bool CGovernanceObject::IsValidLocally(std::string& strError, bool fCheckCollateral)
|
||||
{
|
||||
bool fMissingMasternode = false;
|
||||
|
||||
return IsValidLocally(pindex, strError, fMissingMasternode, fCheckCollateral);
|
||||
return IsValidLocally(strError, fMissingMasternode, fCheckCollateral);
|
||||
}
|
||||
|
||||
bool CGovernanceObject::IsValidLocally(const CBlockIndex* pindex, std::string& strError, bool& fMissingMasternode, bool fCheckCollateral)
|
||||
bool CGovernanceObject::IsValidLocally(std::string& strError, bool& fMissingMasternode, bool fCheckCollateral)
|
||||
{
|
||||
fMissingMasternode = false;
|
||||
if(!pindex) {
|
||||
strError = "Tip is NULL";
|
||||
return true;
|
||||
}
|
||||
|
||||
if(fUnparsable) {
|
||||
strError = "Object data unparseable";
|
||||
|
@ -255,14 +255,14 @@ public:
|
||||
|
||||
// CORE OBJECT FUNCTIONS
|
||||
|
||||
bool IsValidLocally(const CBlockIndex* pindex, std::string& strError, bool fCheckCollateral);
|
||||
bool IsValidLocally(std::string& strError, bool fCheckCollateral);
|
||||
|
||||
bool IsValidLocally(const CBlockIndex* pindex, std::string& strError, bool& fMissingMasternode, bool fCheckCollateral);
|
||||
bool IsValidLocally(std::string& strError, bool& fMissingMasternode, bool fCheckCollateral);
|
||||
|
||||
/// Check the collateral transaction for the budget proposal/finalized budget
|
||||
bool IsCollateralValid(std::string& strError);
|
||||
|
||||
void UpdateLocalValidity(const CBlockIndex *pCurrentBlockIndex);
|
||||
void UpdateLocalValidity();
|
||||
|
||||
void UpdateSentinelVariables();
|
||||
|
||||
|
@ -173,7 +173,7 @@ void CGovernanceManager::ProcessMessage(CNode* pfrom, std::string& strCommand, C
|
||||
// CHECK OBJECT AGAINST LOCAL BLOCKCHAIN
|
||||
|
||||
bool fMasternodeMissing = false;
|
||||
bool fIsValid = govobj.IsValidLocally(pCurrentBlockIndex, strError, fMasternodeMissing, true);
|
||||
bool fIsValid = govobj.IsValidLocally(strError, fMasternodeMissing, true);
|
||||
|
||||
if(fMasternodeMissing) {
|
||||
mapMasternodeOrphanObjects.insert(std::make_pair(nHash, object_time_pair_t(govobj, GetAdjustedTime() + GOVERNANCE_ORPHAN_EXPIRATION_TIME)));
|
||||
@ -293,8 +293,8 @@ bool CGovernanceManager::AddGovernanceObject(CGovernanceObject& govobj)
|
||||
|
||||
// MAKE SURE THIS OBJECT IS OK
|
||||
|
||||
if(!govobj.IsValidLocally(pCurrentBlockIndex, strError, true)) {
|
||||
LogPrintf("CGovernanceManager::AddGovernanceObject -- invalid governance object - %s - (pCurrentBlockIndex nHeight %d) \n", strError, pCurrentBlockIndex->nHeight);
|
||||
if(!govobj.IsValidLocally(strError, true)) {
|
||||
LogPrintf("CGovernanceManager::AddGovernanceObject -- invalid governance object - %s - (nCachedBlockHeight %d) \n", strError, nCachedBlockHeight);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -407,7 +407,7 @@ void CGovernanceManager::UpdateCachesAndClean()
|
||||
// IF CACHE IS NOT DIRTY, WHY DO THIS?
|
||||
if(pObj->IsSetDirtyCache()) {
|
||||
// UPDATE LOCAL VALIDITY AGAINST CRYPTO DATA
|
||||
pObj->UpdateLocalValidity(pCurrentBlockIndex);
|
||||
pObj->UpdateLocalValidity();
|
||||
|
||||
// UPDATE SENTINEL SIGNALING VARIABLES
|
||||
pObj->UpdateSentinelVariables();
|
||||
@ -668,7 +668,7 @@ void CGovernanceManager::Sync(CNode* pfrom, uint256 nProp)
|
||||
LogPrint("gobject", "CGovernanceManager::Sync -- attempting to sync govobj: %s, peer=%d\n", strHash, pfrom->id);
|
||||
|
||||
std::string strError;
|
||||
bool fIsValid = govobj.IsValidLocally(pCurrentBlockIndex, strError, true);
|
||||
bool fIsValid = govobj.IsValidLocally(strError, true);
|
||||
if(!fIsValid) {
|
||||
LogPrintf("CGovernanceManager::Sync -- not syncing invalid govobj: %s, strError = %s, fCachedValid = %d, peer=%d\n",
|
||||
strHash, strError, govobj.IsSetCachedValid(), pfrom->id);
|
||||
@ -887,7 +887,7 @@ void CGovernanceManager::CheckMasternodeOrphanObjects()
|
||||
|
||||
string strError;
|
||||
bool fMasternodeMissing = false;
|
||||
bool fIsValid = govobj.IsValidLocally(pCurrentBlockIndex, strError, fMasternodeMissing, true);
|
||||
bool fIsValid = govobj.IsValidLocally(strError, fMasternodeMissing, true);
|
||||
if(!fIsValid) {
|
||||
if(!fMasternodeMissing) {
|
||||
mapMasternodeOrphanObjects.erase(it++);
|
||||
|
@ -84,15 +84,6 @@ UniValue gobject(const UniValue& params, bool fHelp)
|
||||
|
||||
// ASSEMBLE NEW GOVERNANCE OBJECT FROM USER PARAMETERS
|
||||
|
||||
CBlockIndex* pindex = NULL;
|
||||
{
|
||||
LOCK(cs_main);
|
||||
pindex = chainActive.Tip();
|
||||
}
|
||||
|
||||
std::vector<CMasternodeConfig::CMasternodeEntry> mnEntries;
|
||||
mnEntries = masternodeConfig.getEntries();
|
||||
|
||||
uint256 hashParent;
|
||||
|
||||
// -- attach to root node (root node doesn't really exist, but has a hash of zero)
|
||||
@ -118,7 +109,7 @@ UniValue gobject(const UniValue& params, bool fHelp)
|
||||
}
|
||||
|
||||
std::string strError = "";
|
||||
if(!govobj.IsValidLocally(pindex, strError, false))
|
||||
if(!govobj.IsValidLocally(strError, false))
|
||||
throw JSONRPCError(RPC_INTERNAL_ERROR, "Governance object is not valid - " + govobj.GetHash().ToString() + " - " + strError);
|
||||
|
||||
CWalletTx wtx;
|
||||
@ -161,12 +152,6 @@ UniValue gobject(const UniValue& params, bool fHelp)
|
||||
|
||||
// ASSEMBLE NEW GOVERNANCE OBJECT FROM USER PARAMETERS
|
||||
|
||||
CBlockIndex* pindex = NULL;
|
||||
{
|
||||
LOCK(cs_main);
|
||||
pindex = chainActive.Tip();
|
||||
}
|
||||
|
||||
uint256 txidFee;
|
||||
|
||||
if(params.size() == 6) {
|
||||
@ -217,7 +202,7 @@ UniValue gobject(const UniValue& params, bool fHelp)
|
||||
std::string strHash = govobj.GetHash().ToString();
|
||||
|
||||
std::string strError = "";
|
||||
if(!govobj.IsValidLocally(pindex, strError, true)) {
|
||||
if(!govobj.IsValidLocally(strError, true)) {
|
||||
LogPrintf("gobject(submit) -- Object submission rejected because object is not valid - hash = %s, strError = %s\n", strHash, strError);
|
||||
throw JSONRPCError(RPC_INTERNAL_ERROR, "Governance object is not valid - " + strHash + " - " + strError);
|
||||
}
|
||||
@ -575,17 +560,11 @@ UniValue gobject(const UniValue& params, bool fHelp)
|
||||
|
||||
// SETUP BLOCK INDEX VARIABLE / RESULTS VARIABLE
|
||||
|
||||
CBlockIndex* pindex = NULL;
|
||||
{
|
||||
LOCK(cs_main);
|
||||
pindex = chainActive.Tip();
|
||||
}
|
||||
|
||||
UniValue objResult(UniValue::VOBJ);
|
||||
|
||||
// GET MATCHING GOVERNANCE OBJECTS
|
||||
|
||||
LOCK(governance.cs);
|
||||
LOCK2(cs_main, governance.cs);
|
||||
|
||||
std::vector<CGovernanceObject*> objs = governance.GetAllNewerThan(nStartTime);
|
||||
governance.UpdateLastDiffTime(GetTime());
|
||||
@ -619,7 +598,7 @@ UniValue gobject(const UniValue& params, bool fHelp)
|
||||
|
||||
// REPORT VALIDITY AND CACHING FLAGS FOR VARIOUS SETTINGS
|
||||
std::string strError = "";
|
||||
bObj.push_back(Pair("fBlockchainValidity", pGovObj->IsValidLocally(pindex , strError, false)));
|
||||
bObj.push_back(Pair("fBlockchainValidity", pGovObj->IsValidLocally(strError, false)));
|
||||
bObj.push_back(Pair("IsValidReason", strError.c_str()));
|
||||
bObj.push_back(Pair("fCachedValid", pGovObj->IsSetCachedValid()));
|
||||
bObj.push_back(Pair("fCachedFunding", pGovObj->IsSetCachedFunding()));
|
||||
@ -698,7 +677,7 @@ UniValue gobject(const UniValue& params, bool fHelp)
|
||||
|
||||
// --
|
||||
std::string strError = "";
|
||||
objResult.push_back(Pair("fLocalValidity", pGovObj->IsValidLocally(chainActive.Tip(), strError, false)));
|
||||
objResult.push_back(Pair("fLocalValidity", pGovObj->IsValidLocally(strError, false)));
|
||||
objResult.push_back(Pair("IsValidReason", strError.c_str()));
|
||||
objResult.push_back(Pair("fCachedValid", pGovObj->IsSetCachedValid()));
|
||||
objResult.push_back(Pair("fCachedFunding", pGovObj->IsSetCachedFunding()));
|
||||
|
Loading…
Reference in New Issue
Block a user