V0.12.1.x sentinel pr 2 (#970)

* Improve JSON error reporting in CGovernanceObject::LoadData

* Changed JSON parsing to match current version of sentinel which now sends
correct JSON integers instead of quoting them as strings
This commit is contained in:
Tim Flynn 2016-08-28 18:08:27 -04:00 committed by UdjinM6
parent 0c65204ee6
commit 35e857a5ca
2 changed files with 16 additions and 10 deletions

View File

@ -505,11 +505,8 @@ CSuperblock(uint256& nHash)
UniValue obj = pGovObj->GetJSONObject();
// FIRST WE GET THE START EPOCH, THE DATE WHICH THE PAYMENT SHALL OCCUR
std::string strEpochStart = obj["event_block_height"].get_str();
if (!ParseInt32(strEpochStart, &nEpochStart)) {
throw runtime_error("CSuperblock: Parse error parsing event_block_height");
}
nEpochStart = obj["event_block_height"].get_int();
// NEXT WE GET THE PAYMENT INFORMATION AND RECONSTRUCT THE PAYMENT VECTOR
std::string strAddresses = obj["payment_addresses"].get_str();
std::string strAmounts = obj["payment_amounts"].get_str();

View File

@ -863,16 +863,25 @@ void CGovernanceObject::LoadData()
<< GetDataAsString()
<< endl; );
try
{
try {
UniValue obj = GetJSONObject();
nObjectType = obj["type"].get_int();
}
catch (int e)
{
catch(std::exception& e) {
std::ostringstream ostr;
ostr << "CGovernanceObject::LoadData Error parsing JSON"
<< ", e.what() = " << e.what();
DBG( cout << ostr.str() << endl; );
LogPrintf( ostr.str().c_str() );
return;
}
catch(...) {
std::ostringstream ostr;
ostr << "CGovernanceObject::LoadData Unknown Error parsing JSON";
DBG( cout << ostr.str() << endl; );
LogPrintf( ostr.str().c_str() );
return;
}
}
/**