mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
Drop DBG macros uses from governance modules (#2802)
Replace it with regular "governance" category limited LogPrint-s where it makes sense.
This commit is contained in:
parent
29a9e24b42
commit
5057ad511c
@ -2,8 +2,6 @@
|
|||||||
// Distributed under the MIT/X11 software license, see the accompanying
|
// Distributed under the MIT/X11 software license, see the accompanying
|
||||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
//#define ENABLE_DASH_DEBUG
|
|
||||||
|
|
||||||
#include "governance-classes.h"
|
#include "governance-classes.h"
|
||||||
#include "core_io.h"
|
#include "core_io.h"
|
||||||
#include "init.h"
|
#include "init.h"
|
||||||
@ -36,8 +34,6 @@ std::vector<std::string> SplitBy(const std::string& strCommand, const std::strin
|
|||||||
|
|
||||||
CAmount ParsePaymentAmount(const std::string& strAmount)
|
CAmount ParsePaymentAmount(const std::string& strAmount)
|
||||||
{
|
{
|
||||||
DBG(std::cout << "ParsePaymentAmount Start: strAmount = " << strAmount << std::endl;);
|
|
||||||
|
|
||||||
CAmount nAmount = 0;
|
CAmount nAmount = 0;
|
||||||
if (strAmount.empty()) {
|
if (strAmount.empty()) {
|
||||||
std::ostringstream ostr;
|
std::ostringstream ostr;
|
||||||
@ -91,8 +87,6 @@ CAmount ParsePaymentAmount(const std::string& strAmount)
|
|||||||
throw std::runtime_error(ostr.str());
|
throw std::runtime_error(ostr.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
DBG(std::cout << "ParsePaymentAmount Returning true nAmount = " << nAmount << std::endl;);
|
|
||||||
|
|
||||||
return nAmount;
|
return nAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,17 +96,12 @@ CAmount ParsePaymentAmount(const std::string& strAmount)
|
|||||||
|
|
||||||
bool CGovernanceTriggerManager::AddNewTrigger(uint256 nHash)
|
bool CGovernanceTriggerManager::AddNewTrigger(uint256 nHash)
|
||||||
{
|
{
|
||||||
DBG(std::cout << "CGovernanceTriggerManager::AddNewTrigger: Start" << std::endl;);
|
|
||||||
AssertLockHeld(governance.cs);
|
AssertLockHeld(governance.cs);
|
||||||
|
|
||||||
// IF WE ALREADY HAVE THIS HASH, RETURN
|
// IF WE ALREADY HAVE THIS HASH, RETURN
|
||||||
if (mapTrigger.count(nHash)) {
|
if (mapTrigger.count(nHash)) {
|
||||||
DBG(
|
LogPrint("gobject", "CGovernanceTriggerManager::AddNewTrigger -- Already have hash, nHash = %s, count = %d, size = %s\n",
|
||||||
std::cout << "CGovernanceTriggerManager::AddNewTrigger: Already have hash"
|
nHash.GetHex(), mapTrigger.count(nHash), mapTrigger.size());
|
||||||
<< ", nHash = " << nHash.GetHex()
|
|
||||||
<< ", count = " << mapTrigger.count(nHash)
|
|
||||||
<< ", mapTrigger.size() = " << mapTrigger.size()
|
|
||||||
<< std::endl;);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,24 +110,17 @@ bool CGovernanceTriggerManager::AddNewTrigger(uint256 nHash)
|
|||||||
CSuperblock_sptr pSuperblockTmp(new CSuperblock(nHash));
|
CSuperblock_sptr pSuperblockTmp(new CSuperblock(nHash));
|
||||||
pSuperblock = pSuperblockTmp;
|
pSuperblock = pSuperblockTmp;
|
||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) {
|
||||||
DBG(std::cout << "CGovernanceTriggerManager::AddNewTrigger Error creating superblock"
|
|
||||||
<< ", e.what() = " << e.what()
|
|
||||||
<< std::endl;);
|
|
||||||
LogPrintf("CGovernanceTriggerManager::AddNewTrigger -- Error creating superblock: %s\n", e.what());
|
LogPrintf("CGovernanceTriggerManager::AddNewTrigger -- Error creating superblock: %s\n", e.what());
|
||||||
return false;
|
return false;
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
LogPrintf("CGovernanceTriggerManager::AddNewTrigger: Unknown Error creating superblock\n");
|
LogPrintf("CGovernanceTriggerManager::AddNewTrigger: Unknown Error creating superblock\n");
|
||||||
DBG(std::cout << "CGovernanceTriggerManager::AddNewTrigger Error creating superblock catchall" << std::endl;);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
pSuperblock->SetStatus(SEEN_OBJECT_IS_VALID);
|
pSuperblock->SetStatus(SEEN_OBJECT_IS_VALID);
|
||||||
|
|
||||||
DBG(std::cout << "CGovernanceTriggerManager::AddNewTrigger: Inserting trigger" << std::endl;);
|
|
||||||
mapTrigger.insert(std::make_pair(nHash, pSuperblock));
|
mapTrigger.insert(std::make_pair(nHash, pSuperblock));
|
||||||
|
|
||||||
DBG(std::cout << "CGovernanceTriggerManager::AddNewTrigger: End" << std::endl;);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,12 +132,9 @@ bool CGovernanceTriggerManager::AddNewTrigger(uint256 nHash)
|
|||||||
|
|
||||||
void CGovernanceTriggerManager::CleanAndRemove()
|
void CGovernanceTriggerManager::CleanAndRemove()
|
||||||
{
|
{
|
||||||
LogPrint("gobject", "CGovernanceTriggerManager::CleanAndRemove -- Start\n");
|
|
||||||
DBG(std::cout << "CGovernanceTriggerManager::CleanAndRemove: Start" << std::endl;);
|
|
||||||
AssertLockHeld(governance.cs);
|
AssertLockHeld(governance.cs);
|
||||||
|
|
||||||
// Remove triggers that are invalid or expired
|
// Remove triggers that are invalid or expired
|
||||||
DBG(std::cout << "CGovernanceTriggerManager::CleanAndRemove: mapTrigger.size() = " << mapTrigger.size() << std::endl;);
|
|
||||||
LogPrint("gobject", "CGovernanceTriggerManager::CleanAndRemove -- mapTrigger.size() = %d\n", mapTrigger.size());
|
LogPrint("gobject", "CGovernanceTriggerManager::CleanAndRemove -- mapTrigger.size() = %d\n", mapTrigger.size());
|
||||||
|
|
||||||
trigger_m_it it = mapTrigger.begin();
|
trigger_m_it it = mapTrigger.begin();
|
||||||
@ -164,18 +143,15 @@ void CGovernanceTriggerManager::CleanAndRemove()
|
|||||||
CGovernanceObject* pObj = nullptr;
|
CGovernanceObject* pObj = nullptr;
|
||||||
CSuperblock_sptr& pSuperblock = it->second;
|
CSuperblock_sptr& pSuperblock = it->second;
|
||||||
if (!pSuperblock) {
|
if (!pSuperblock) {
|
||||||
DBG(std::cout << "CGovernanceTriggerManager::CleanAndRemove: NULL superblock marked for removal" << std::endl;);
|
|
||||||
LogPrint("gobject", "CGovernanceTriggerManager::CleanAndRemove -- NULL superblock marked for removal\n");
|
LogPrint("gobject", "CGovernanceTriggerManager::CleanAndRemove -- NULL superblock marked for removal\n");
|
||||||
remove = true;
|
remove = true;
|
||||||
} else {
|
} else {
|
||||||
pObj = governance.FindGovernanceObject(it->first);
|
pObj = governance.FindGovernanceObject(it->first);
|
||||||
if (!pObj || pObj->GetObjectType() != GOVERNANCE_OBJECT_TRIGGER) {
|
if (!pObj || pObj->GetObjectType() != GOVERNANCE_OBJECT_TRIGGER) {
|
||||||
DBG(std::cout << "CGovernanceTriggerManager::CleanAndRemove: Unknown or non-trigger superblock" << std::endl;);
|
|
||||||
LogPrint("gobject", "CGovernanceTriggerManager::CleanAndRemove -- Unknown or non-trigger superblock\n");
|
LogPrint("gobject", "CGovernanceTriggerManager::CleanAndRemove -- Unknown or non-trigger superblock\n");
|
||||||
pSuperblock->SetStatus(SEEN_OBJECT_ERROR_INVALID);
|
pSuperblock->SetStatus(SEEN_OBJECT_ERROR_INVALID);
|
||||||
}
|
}
|
||||||
|
|
||||||
DBG(std::cout << "CGovernanceTriggerManager::CleanAndRemove: superblock status = " << pSuperblock->GetStatus() << std::endl;);
|
|
||||||
LogPrint("gobject", "CGovernanceTriggerManager::CleanAndRemove -- superblock status = %d\n", pSuperblock->GetStatus());
|
LogPrint("gobject", "CGovernanceTriggerManager::CleanAndRemove -- superblock status = %d\n", pSuperblock->GetStatus());
|
||||||
switch (pSuperblock->GetStatus()) {
|
switch (pSuperblock->GetStatus()) {
|
||||||
case SEEN_OBJECT_ERROR_INVALID:
|
case SEEN_OBJECT_ERROR_INVALID:
|
||||||
@ -194,15 +170,11 @@ void CGovernanceTriggerManager::CleanAndRemove()
|
|||||||
LogPrint("gobject", "CGovernanceTriggerManager::CleanAndRemove -- %smarked for removal\n", remove ? "" : "NOT ");
|
LogPrint("gobject", "CGovernanceTriggerManager::CleanAndRemove -- %smarked for removal\n", remove ? "" : "NOT ");
|
||||||
|
|
||||||
if (remove) {
|
if (remove) {
|
||||||
DBG(
|
std::string strDataAsPlainString = "NULL";
|
||||||
std::string strDataAsPlainString = "NULL";
|
if (pObj) {
|
||||||
if (pObj) {
|
strDataAsPlainString = pObj->GetDataAsPlainString();
|
||||||
strDataAsPlainString = pObj->GetDataAsPlainString();
|
}
|
||||||
}
|
LogPrint("gobject", "CGovernanceTriggerManager::CleanAndRemove -- Removing trigger object %s\n", strDataAsPlainString);
|
||||||
std::cout << "CGovernanceTriggerManager::CleanAndRemove: Removing object: "
|
|
||||||
<< strDataAsPlainString
|
|
||||||
<< std::endl;);
|
|
||||||
LogPrint("gobject", "CGovernanceTriggerManager::CleanAndRemove -- Removing trigger object\n");
|
|
||||||
// mark corresponding object for deletion
|
// mark corresponding object for deletion
|
||||||
if (pObj) {
|
if (pObj) {
|
||||||
pObj->fCachedDelete = true;
|
pObj->fCachedDelete = true;
|
||||||
@ -216,8 +188,6 @@ void CGovernanceTriggerManager::CleanAndRemove()
|
|||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DBG(std::cout << "CGovernanceTriggerManager::CleanAndRemove: End" << std::endl;);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -232,19 +202,14 @@ std::vector<CSuperblock_sptr> CGovernanceTriggerManager::GetActiveTriggers()
|
|||||||
AssertLockHeld(governance.cs);
|
AssertLockHeld(governance.cs);
|
||||||
std::vector<CSuperblock_sptr> vecResults;
|
std::vector<CSuperblock_sptr> vecResults;
|
||||||
|
|
||||||
DBG(std::cout << "GetActiveTriggers: mapTrigger.size() = " << mapTrigger.size() << std::endl;);
|
|
||||||
|
|
||||||
// LOOK AT THESE OBJECTS AND COMPILE A VALID LIST OF TRIGGERS
|
// LOOK AT THESE OBJECTS AND COMPILE A VALID LIST OF TRIGGERS
|
||||||
for (const auto& pair : mapTrigger) {
|
for (const auto& pair : mapTrigger) {
|
||||||
CGovernanceObject* pObj = governance.FindGovernanceObject(pair.first);
|
CGovernanceObject* pObj = governance.FindGovernanceObject(pair.first);
|
||||||
if (pObj) {
|
if (pObj) {
|
||||||
DBG(std::cout << "GetActiveTriggers: pObj->GetDataAsPlainString() = " << pObj->GetDataAsPlainString() << std::endl;);
|
|
||||||
vecResults.push_back(pair.second);
|
vecResults.push_back(pair.second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DBG(std::cout << "GetActiveTriggers: vecResults.size() = " << vecResults.size() << std::endl;);
|
|
||||||
|
|
||||||
return vecResults;
|
return vecResults;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,12 +232,9 @@ bool CSuperblockManager::IsSuperblockTriggered(int nBlockHeight)
|
|||||||
|
|
||||||
LogPrint("gobject", "CSuperblockManager::IsSuperblockTriggered -- vecTriggers.size() = %d\n", vecTriggers.size());
|
LogPrint("gobject", "CSuperblockManager::IsSuperblockTriggered -- vecTriggers.size() = %d\n", vecTriggers.size());
|
||||||
|
|
||||||
DBG(std::cout << "IsSuperblockTriggered Number triggers = " << vecTriggers.size() << std::endl;);
|
|
||||||
|
|
||||||
for (const auto& pSuperblock : vecTriggers) {
|
for (const auto& pSuperblock : vecTriggers) {
|
||||||
if (!pSuperblock) {
|
if (!pSuperblock) {
|
||||||
LogPrintf("CSuperblockManager::IsSuperblockTriggered -- Non-superblock found, continuing\n");
|
LogPrintf("CSuperblockManager::IsSuperblockTriggered -- Non-superblock found, continuing\n");
|
||||||
DBG(std::cout << "IsSuperblockTriggered Not a superblock, continuing " << std::endl;);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -280,7 +242,6 @@ bool CSuperblockManager::IsSuperblockTriggered(int nBlockHeight)
|
|||||||
|
|
||||||
if (!pObj) {
|
if (!pObj) {
|
||||||
LogPrintf("CSuperblockManager::IsSuperblockTriggered -- pObj == nullptr, continuing\n");
|
LogPrintf("CSuperblockManager::IsSuperblockTriggered -- pObj == nullptr, continuing\n");
|
||||||
DBG(std::cout << "IsSuperblockTriggered pObj is NULL, continuing" << std::endl;);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,10 +253,6 @@ bool CSuperblockManager::IsSuperblockTriggered(int nBlockHeight)
|
|||||||
LogPrint("gobject", "CSuperblockManager::IsSuperblockTriggered -- block height doesn't match nBlockHeight = %d, blockStart = %d, continuing\n",
|
LogPrint("gobject", "CSuperblockManager::IsSuperblockTriggered -- block height doesn't match nBlockHeight = %d, blockStart = %d, continuing\n",
|
||||||
nBlockHeight,
|
nBlockHeight,
|
||||||
pSuperblock->GetBlockHeight());
|
pSuperblock->GetBlockHeight());
|
||||||
DBG(std::cout << "IsSuperblockTriggered Not the target block, continuing"
|
|
||||||
<< ", nBlockHeight = " << nBlockHeight
|
|
||||||
<< ", superblock->GetBlockHeight() = " << pSuperblock->GetBlockHeight()
|
|
||||||
<< std::endl;);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -305,11 +262,9 @@ bool CSuperblockManager::IsSuperblockTriggered(int nBlockHeight)
|
|||||||
|
|
||||||
if (pObj->IsSetCachedFunding()) {
|
if (pObj->IsSetCachedFunding()) {
|
||||||
LogPrint("gobject", "CSuperblockManager::IsSuperblockTriggered -- fCacheFunding = true, returning true\n");
|
LogPrint("gobject", "CSuperblockManager::IsSuperblockTriggered -- fCacheFunding = true, returning true\n");
|
||||||
DBG(std::cout << "IsSuperblockTriggered returning true" << std::endl;);
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
LogPrint("gobject", "CSuperblockManager::IsSuperblockTriggered -- fCacheFunding = false, continuing\n");
|
LogPrint("gobject", "CSuperblockManager::IsSuperblockTriggered -- fCacheFunding = false, continuing\n");
|
||||||
DBG(std::cout << "IsSuperblockTriggered No fCachedFunding, continuing" << std::endl;);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -328,31 +283,22 @@ bool CSuperblockManager::GetBestSuperblock(CSuperblock_sptr& pSuperblockRet, int
|
|||||||
int nYesCount = 0;
|
int nYesCount = 0;
|
||||||
|
|
||||||
for (const auto& pSuperblock : vecTriggers) {
|
for (const auto& pSuperblock : vecTriggers) {
|
||||||
if (!pSuperblock) {
|
if (!pSuperblock || nBlockHeight != pSuperblock->GetBlockHeight()) {
|
||||||
DBG(std::cout << "GetBestSuperblock Not a superblock, continuing" << std::endl;);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
CGovernanceObject* pObj = pSuperblock->GetGovernanceObject();
|
CGovernanceObject* pObj = pSuperblock->GetGovernanceObject();
|
||||||
|
|
||||||
if (!pObj) {
|
if (!pObj) {
|
||||||
DBG(std::cout << "GetBestSuperblock pObj is NULL, continuing" << std::endl;);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nBlockHeight != pSuperblock->GetBlockHeight()) {
|
|
||||||
DBG(std::cout << "GetBestSuperblock Not the target block, continuing" << std::endl;);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// DO WE HAVE A NEW WINNER?
|
// DO WE HAVE A NEW WINNER?
|
||||||
|
|
||||||
int nTempYesCount = pObj->GetAbsoluteYesCount(VOTE_SIGNAL_FUNDING);
|
int nTempYesCount = pObj->GetAbsoluteYesCount(VOTE_SIGNAL_FUNDING);
|
||||||
DBG(std::cout << "GetBestSuperblock nTempYesCount = " << nTempYesCount << std::endl;);
|
|
||||||
if (nTempYesCount > nYesCount) {
|
if (nTempYesCount > nYesCount) {
|
||||||
nYesCount = nTempYesCount;
|
nYesCount = nTempYesCount;
|
||||||
pSuperblockRet = pSuperblock;
|
pSuperblockRet = pSuperblock;
|
||||||
DBG(std::cout << "GetBestSuperblock Valid superblock found, pSuperblock set" << std::endl;);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -367,8 +313,6 @@ bool CSuperblockManager::GetBestSuperblock(CSuperblock_sptr& pSuperblockRet, int
|
|||||||
|
|
||||||
bool CSuperblockManager::GetSuperblockPayments(int nBlockHeight, std::vector<CTxOut>& voutSuperblockRet)
|
bool CSuperblockManager::GetSuperblockPayments(int nBlockHeight, std::vector<CTxOut>& voutSuperblockRet)
|
||||||
{
|
{
|
||||||
DBG(std::cout << "CSuperblockManager::GetSuperblockPayments Start" << std::endl;);
|
|
||||||
|
|
||||||
LOCK(governance.cs);
|
LOCK(governance.cs);
|
||||||
|
|
||||||
// GET THE BEST SUPERBLOCK FOR THIS BLOCK HEIGHT
|
// GET THE BEST SUPERBLOCK FOR THIS BLOCK HEIGHT
|
||||||
@ -376,7 +320,6 @@ bool CSuperblockManager::GetSuperblockPayments(int nBlockHeight, std::vector<CTx
|
|||||||
CSuperblock_sptr pSuperblock;
|
CSuperblock_sptr pSuperblock;
|
||||||
if (!CSuperblockManager::GetBestSuperblock(pSuperblock, nBlockHeight)) {
|
if (!CSuperblockManager::GetBestSuperblock(pSuperblock, nBlockHeight)) {
|
||||||
LogPrint("gobject", "CSuperblockManager::GetSuperblockPayments -- Can't find superblock for height %d\n", nBlockHeight);
|
LogPrint("gobject", "CSuperblockManager::GetSuperblockPayments -- Can't find superblock for height %d\n", nBlockHeight);
|
||||||
DBG(std::cout << "CSuperblockManager::GetSuperblockPayments Failed to get superblock for height, returning" << std::endl;);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -386,7 +329,6 @@ bool CSuperblockManager::GetSuperblockPayments(int nBlockHeight, std::vector<CTx
|
|||||||
// GET SUPERBLOCK OUTPUTS
|
// GET SUPERBLOCK OUTPUTS
|
||||||
|
|
||||||
// Superblock payments will be appended to the end of the coinbase vout vector
|
// Superblock payments will be appended to the end of the coinbase vout vector
|
||||||
DBG(std::cout << "CSuperblockManager::GetSuperblockPayments Number payments: " << pSuperblock->CountPayments() << std::endl;);
|
|
||||||
|
|
||||||
// TODO: How many payments can we add before things blow up?
|
// TODO: How many payments can we add before things blow up?
|
||||||
// Consider at least following limits:
|
// Consider at least following limits:
|
||||||
@ -394,9 +336,7 @@ bool CSuperblockManager::GetSuperblockPayments(int nBlockHeight, std::vector<CTx
|
|||||||
// - max "budget" available
|
// - max "budget" available
|
||||||
for (int i = 0; i < pSuperblock->CountPayments(); i++) {
|
for (int i = 0; i < pSuperblock->CountPayments(); i++) {
|
||||||
CGovernancePayment payment;
|
CGovernancePayment payment;
|
||||||
DBG(std::cout << "CSuperblockManager::GetSuperblockPayments i = " << i << std::endl;);
|
|
||||||
if (pSuperblock->GetPayment(i, payment)) {
|
if (pSuperblock->GetPayment(i, payment)) {
|
||||||
DBG(std::cout << "CSuperblockManager::GetSuperblockPayments Payment found " << std::endl;);
|
|
||||||
// SET COINBASE OUTPUT TO SUPERBLOCK SETTING
|
// SET COINBASE OUTPUT TO SUPERBLOCK SETTING
|
||||||
|
|
||||||
CTxOut txout = CTxOut(payment.nAmount, payment.script);
|
CTxOut txout = CTxOut(payment.nAmount, payment.script);
|
||||||
@ -410,16 +350,13 @@ bool CSuperblockManager::GetSuperblockPayments(int nBlockHeight, std::vector<CTx
|
|||||||
|
|
||||||
// TODO: PRINT NICE N.N DASH OUTPUT
|
// TODO: PRINT NICE N.N DASH OUTPUT
|
||||||
|
|
||||||
DBG(std::cout << "CSuperblockManager::GetSuperblockPayments Before LogPrintf call, nAmount = " << payment.nAmount << std::endl;);
|
LogPrint("gobject", "CSuperblockManager::GetSuperblockPayments -- NEW Superblock: output %d (addr %s, amount %lld)\n",
|
||||||
LogPrintf("NEW Superblock : output %d (addr %s, amount %d)\n", i, address2.ToString(), payment.nAmount);
|
i, address2.ToString(), payment.nAmount);
|
||||||
DBG(std::cout << "CSuperblockManager::GetSuperblockPayments After LogPrintf call " << std::endl;);
|
|
||||||
} else {
|
} else {
|
||||||
DBG(std::cout << "CSuperblockManager::GetSuperblockPayments Payment not found " << std::endl;);
|
LogPrint("gobject", "CSuperblockManager::GetSuperblockPayments -- Payment not found\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DBG(std::cout << "CSuperblockManager::GetSuperblockPayments End" << std::endl;);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -464,22 +401,16 @@ CSuperblock::
|
|||||||
nStatus(SEEN_OBJECT_UNKNOWN),
|
nStatus(SEEN_OBJECT_UNKNOWN),
|
||||||
vecPayments()
|
vecPayments()
|
||||||
{
|
{
|
||||||
DBG(std::cout << "CSuperblock Constructor Start" << std::endl;);
|
|
||||||
|
|
||||||
CGovernanceObject* pGovObj = GetGovernanceObject();
|
CGovernanceObject* pGovObj = GetGovernanceObject();
|
||||||
|
|
||||||
if (!pGovObj) {
|
if (!pGovObj) {
|
||||||
DBG(std::cout << "CSuperblock Constructor pGovObjIn is NULL, returning" << std::endl;);
|
|
||||||
throw std::runtime_error("CSuperblock: Failed to find Governance Object");
|
throw std::runtime_error("CSuperblock: Failed to find Governance Object");
|
||||||
}
|
}
|
||||||
|
|
||||||
DBG(std::cout << "CSuperblock Constructor pGovObj : "
|
LogPrint("gobject", "CSuperblock -- Constructor pGovObj: %s, nObjectType = %d\n",
|
||||||
<< pGovObj->GetDataAsPlainString()
|
pGovObj->GetDataAsPlainString(), pGovObj->GetObjectType());
|
||||||
<< ", nObjectType = " << pGovObj->GetObjectType()
|
|
||||||
<< std::endl;);
|
|
||||||
|
|
||||||
if (pGovObj->GetObjectType() != GOVERNANCE_OBJECT_TRIGGER) {
|
if (pGovObj->GetObjectType() != GOVERNANCE_OBJECT_TRIGGER) {
|
||||||
DBG(std::cout << "CSuperblock Constructor pGovObj not a trigger, returning" << std::endl;);
|
|
||||||
throw std::runtime_error("CSuperblock: Governance Object not a trigger");
|
throw std::runtime_error("CSuperblock: Governance Object not a trigger");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -495,8 +426,6 @@ CSuperblock::
|
|||||||
|
|
||||||
LogPrint("gobject", "CSuperblock -- nBlockHeight = %d, strAddresses = %s, strAmounts = %s, vecPayments.size() = %d\n",
|
LogPrint("gobject", "CSuperblock -- nBlockHeight = %d, strAddresses = %s, strAmounts = %s, vecPayments.size() = %d\n",
|
||||||
nBlockHeight, strAddresses, strAmounts, vecPayments.size());
|
nBlockHeight, strAddresses, strAmounts, vecPayments.size());
|
||||||
|
|
||||||
DBG(std::cout << "CSuperblock Constructor End" << std::endl;);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -580,8 +509,6 @@ void CSuperblock::ParsePaymentSchedule(const std::string& strPaymentAddresses, c
|
|||||||
AMOUNTS = [AMOUNT1|2|3|4|5|6]
|
AMOUNTS = [AMOUNT1|2|3|4|5|6]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
DBG(std::cout << "CSuperblock::ParsePaymentSchedule vecParsed1.size() = " << vecParsed1.size() << std::endl;);
|
|
||||||
|
|
||||||
for (int i = 0; i < (int)vecParsed1.size(); i++) {
|
for (int i = 0; i < (int)vecParsed1.size(); i++) {
|
||||||
CBitcoinAddress address(vecParsed1[i]);
|
CBitcoinAddress address(vecParsed1[i]);
|
||||||
if (!address.IsValid()) {
|
if (!address.IsValid()) {
|
||||||
@ -603,16 +530,9 @@ void CSuperblock::ParsePaymentSchedule(const std::string& strPaymentAddresses, c
|
|||||||
throw std::runtime_error(ostr.str());
|
throw std::runtime_error(ostr.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
DBG(std::cout << "CSuperblock::ParsePaymentSchedule i = " << i
|
|
||||||
<< ", vecParsed2[i] = " << vecParsed2[i]
|
|
||||||
<< std::endl;);
|
|
||||||
|
|
||||||
CAmount nAmount = ParsePaymentAmount(vecParsed2[i]);
|
CAmount nAmount = ParsePaymentAmount(vecParsed2[i]);
|
||||||
|
|
||||||
DBG(std::cout << "CSuperblock::ParsePaymentSchedule: "
|
LogPrint("gobject", "CSuperblock::ParsePaymentSchedule -- i = %d, amount string = %s, nAmount = %lld\n", i, vecParsed2[i], nAmount);
|
||||||
<< "amount string = " << vecParsed2[i]
|
|
||||||
<< ", nAmount = " << nAmount
|
|
||||||
<< std::endl;);
|
|
||||||
|
|
||||||
CGovernancePayment payment(address, nAmount);
|
CGovernancePayment payment(address, nAmount);
|
||||||
if (payment.IsValid()) {
|
if (payment.IsValid()) {
|
||||||
@ -676,7 +596,7 @@ bool CSuperblock::IsValid(const CTransaction& txNew, int nBlockHeight, CAmount b
|
|||||||
int nPayments = CountPayments();
|
int nPayments = CountPayments();
|
||||||
int nMinerAndMasternodePayments = nOutputs - nPayments;
|
int nMinerAndMasternodePayments = nOutputs - nPayments;
|
||||||
|
|
||||||
LogPrint("gobject", "CSuperblock::IsValid nOutputs = %d, nPayments = %d, GetDataAsHexString = %s\n",
|
LogPrint("gobject", "CSuperblock::IsValid -- nOutputs = %d, nPayments = %d, GetDataAsHexString = %s\n",
|
||||||
nOutputs, nPayments, GetGovernanceObject()->GetDataAsHexString());
|
nOutputs, nPayments, GetGovernanceObject()->GetDataAsHexString());
|
||||||
|
|
||||||
// We require an exact match (including order) between the expected
|
// We require an exact match (including order) between the expected
|
||||||
|
@ -4,8 +4,6 @@
|
|||||||
#ifndef GOVERNANCE_CLASSES_H
|
#ifndef GOVERNANCE_CLASSES_H
|
||||||
#define GOVERNANCE_CLASSES_H
|
#define GOVERNANCE_CLASSES_H
|
||||||
|
|
||||||
//#define ENABLE_DASH_DEBUG
|
|
||||||
|
|
||||||
#include "base58.h"
|
#include "base58.h"
|
||||||
#include "governance.h"
|
#include "governance.h"
|
||||||
#include "key.h"
|
#include "key.h"
|
||||||
|
@ -302,8 +302,6 @@ uint256 CGovernanceObject::GetHash() const
|
|||||||
ss << vchSig;
|
ss << vchSig;
|
||||||
// fee_tx is left out on purpose
|
// fee_tx is left out on purpose
|
||||||
|
|
||||||
DBG(printf("CGovernanceObject::GetHash %i %li %s\n", nRevision, nTime, GetDataAsHexString().c_str()););
|
|
||||||
|
|
||||||
return ss.GetHash();
|
return ss.GetHash();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -382,11 +380,7 @@ void CGovernanceObject::LoadData()
|
|||||||
// ATTEMPT TO LOAD JSON STRING FROM VCHDATA
|
// ATTEMPT TO LOAD JSON STRING FROM VCHDATA
|
||||||
UniValue objResult(UniValue::VOBJ);
|
UniValue objResult(UniValue::VOBJ);
|
||||||
GetData(objResult);
|
GetData(objResult);
|
||||||
|
LogPrint("gobject", "CGovernanceObject::LoadData -- GetDataAsPlainString = %s\n", GetDataAsPlainString());
|
||||||
DBG(std::cout << "CGovernanceObject::LoadData GetDataAsPlainString = "
|
|
||||||
<< GetDataAsPlainString()
|
|
||||||
<< std::endl;);
|
|
||||||
|
|
||||||
UniValue obj = GetJSONObject();
|
UniValue obj = GetJSONObject();
|
||||||
nObjectType = obj["type"].get_int();
|
nObjectType = obj["type"].get_int();
|
||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) {
|
||||||
@ -394,14 +388,12 @@ void CGovernanceObject::LoadData()
|
|||||||
std::ostringstream ostr;
|
std::ostringstream ostr;
|
||||||
ostr << "CGovernanceObject::LoadData Error parsing JSON"
|
ostr << "CGovernanceObject::LoadData Error parsing JSON"
|
||||||
<< ", e.what() = " << e.what();
|
<< ", e.what() = " << e.what();
|
||||||
DBG(std::cout << ostr.str() << std::endl;);
|
|
||||||
LogPrintf("%s\n", ostr.str());
|
LogPrintf("%s\n", ostr.str());
|
||||||
return;
|
return;
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
fUnparsable = true;
|
fUnparsable = true;
|
||||||
std::ostringstream ostr;
|
std::ostringstream ostr;
|
||||||
ostr << "CGovernanceObject::LoadData Unknown Error parsing JSON";
|
ostr << "CGovernanceObject::LoadData Unknown Error parsing JSON";
|
||||||
DBG(std::cout << ostr.str() << std::endl;);
|
|
||||||
LogPrintf("%s\n", ostr.str());
|
LogPrintf("%s\n", ostr.str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -573,29 +565,20 @@ bool CGovernanceObject::IsCollateralValid(std::string& strError, bool& fMissingC
|
|||||||
CScript findScript;
|
CScript findScript;
|
||||||
findScript << OP_RETURN << ToByteVector(nExpectedHash);
|
findScript << OP_RETURN << ToByteVector(nExpectedHash);
|
||||||
|
|
||||||
DBG(std::cout << "IsCollateralValid: txCollateral->vout.size() = " << txCollateral->vout.size() << std::endl;);
|
LogPrint("gobject", "CGovernanceObject::IsCollateralValid -- txCollateral->vout.size() = %s, findScript = %s, nMinFee = %lld\n",
|
||||||
|
txCollateral->vout.size(), ScriptToAsmStr(findScript, false), nMinFee);
|
||||||
DBG(std::cout << "IsCollateralValid: findScript = " << ScriptToAsmStr(findScript, false) << std::endl;);
|
|
||||||
|
|
||||||
DBG(std::cout << "IsCollateralValid: nMinFee = " << nMinFee << std::endl;);
|
|
||||||
|
|
||||||
|
|
||||||
bool foundOpReturn = false;
|
bool foundOpReturn = false;
|
||||||
for (const auto& output : txCollateral->vout) {
|
for (const auto& output : txCollateral->vout) {
|
||||||
DBG(std::cout << "IsCollateralValid txout : " << output.ToString()
|
LogPrint("gobject", "CGovernanceObject::IsCollateralValid -- txout = %s, output.nValue = %lld, output.scriptPubKey = %s\n",
|
||||||
<< ", output.nValue = " << output.nValue
|
output.ToString(), output.nValue, ScriptToAsmStr(output.scriptPubKey, false));
|
||||||
<< ", output.scriptPubKey = " << ScriptToAsmStr(output.scriptPubKey, false)
|
|
||||||
<< std::endl;);
|
|
||||||
if (!output.scriptPubKey.IsPayToPublicKeyHash() && !output.scriptPubKey.IsUnspendable()) {
|
if (!output.scriptPubKey.IsPayToPublicKeyHash() && !output.scriptPubKey.IsUnspendable()) {
|
||||||
strError = strprintf("Invalid Script %s", txCollateral->ToString());
|
strError = strprintf("Invalid Script %s", txCollateral->ToString());
|
||||||
LogPrintf("CGovernanceObject::IsCollateralValid -- %s\n", strError);
|
LogPrintf("CGovernanceObject::IsCollateralValid -- %s\n", strError);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (output.scriptPubKey == findScript && output.nValue >= nMinFee) {
|
if (output.scriptPubKey == findScript && output.nValue >= nMinFee) {
|
||||||
DBG(std::cout << "IsCollateralValid foundOpReturn = true" << std::endl;);
|
|
||||||
foundOpReturn = true;
|
foundOpReturn = true;
|
||||||
} else {
|
|
||||||
DBG(std::cout << "IsCollateralValid No match, continuing" << std::endl;);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,8 +5,6 @@
|
|||||||
#ifndef GOVERNANCE_OBJECT_H
|
#ifndef GOVERNANCE_OBJECT_H
|
||||||
#define GOVERNANCE_OBJECT_H
|
#define GOVERNANCE_OBJECT_H
|
||||||
|
|
||||||
//#define ENABLE_DASH_DEBUG
|
|
||||||
|
|
||||||
#include "cachemultimap.h"
|
#include "cachemultimap.h"
|
||||||
#include "governance-exceptions.h"
|
#include "governance-exceptions.h"
|
||||||
#include "governance-vote.h"
|
#include "governance-vote.h"
|
||||||
|
@ -296,8 +296,6 @@ void CGovernanceManager::CheckOrphanVotes(CGovernanceObject& govobj, CGovernance
|
|||||||
|
|
||||||
void CGovernanceManager::AddGovernanceObject(CGovernanceObject& govobj, CConnman& connman, CNode* pfrom)
|
void CGovernanceManager::AddGovernanceObject(CGovernanceObject& govobj, CConnman& connman, CNode* pfrom)
|
||||||
{
|
{
|
||||||
DBG(std::cout << "CGovernanceManager::AddGovernanceObject START" << std::endl;);
|
|
||||||
|
|
||||||
uint256 nHash = govobj.GetHash();
|
uint256 nHash = govobj.GetHash();
|
||||||
std::string strHash = nHash.ToString();
|
std::string strHash = nHash.ToString();
|
||||||
|
|
||||||
@ -328,13 +326,10 @@ void CGovernanceManager::AddGovernanceObject(CGovernanceObject& govobj, CConnman
|
|||||||
|
|
||||||
// SHOULD WE ADD THIS OBJECT TO ANY OTHER MANANGERS?
|
// SHOULD WE ADD THIS OBJECT TO ANY OTHER MANANGERS?
|
||||||
|
|
||||||
DBG(std::cout << "CGovernanceManager::AddGovernanceObject Before trigger block, GetDataAsPlainString = "
|
LogPrint("gobject", "CGovernanceManager::AddGovernanceObject -- Before trigger block, GetDataAsPlainString = %s, nObjectType = %d\n",
|
||||||
<< govobj.GetDataAsPlainString()
|
govobj.GetDataAsPlainString(), govobj.nObjectType);
|
||||||
<< ", nObjectType = " << govobj.nObjectType
|
|
||||||
<< std::endl;);
|
|
||||||
|
|
||||||
if (govobj.nObjectType == GOVERNANCE_OBJECT_TRIGGER) {
|
if (govobj.nObjectType == GOVERNANCE_OBJECT_TRIGGER) {
|
||||||
DBG(std::cout << "CGovernanceManager::AddGovernanceObject Before AddNewTrigger" << std::endl;);
|
|
||||||
if (!triggerman.AddNewTrigger(nHash)) {
|
if (!triggerman.AddNewTrigger(nHash)) {
|
||||||
LogPrint("gobject", "CGovernanceManager::AddGovernanceObject -- undo adding invalid trigger object: hash = %s\n", nHash.ToString());
|
LogPrint("gobject", "CGovernanceManager::AddGovernanceObject -- undo adding invalid trigger object: hash = %s\n", nHash.ToString());
|
||||||
CGovernanceObject& objref = objpair.first->second;
|
CGovernanceObject& objref = objpair.first->second;
|
||||||
@ -344,7 +339,6 @@ void CGovernanceManager::AddGovernanceObject(CGovernanceObject& govobj, CConnman
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DBG(std::cout << "CGovernanceManager::AddGovernanceObject After AddNewTrigger" << std::endl;);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LogPrintf("CGovernanceManager::AddGovernanceObject -- %s new, received from %s\n", strHash, pfrom ? pfrom->GetAddrName() : "nullptr");
|
LogPrintf("CGovernanceManager::AddGovernanceObject -- %s new, received from %s\n", strHash, pfrom ? pfrom->GetAddrName() : "nullptr");
|
||||||
@ -362,9 +356,6 @@ void CGovernanceManager::AddGovernanceObject(CGovernanceObject& govobj, CConnman
|
|||||||
|
|
||||||
// SEND NOTIFICATION TO SCRIPT/ZMQ
|
// SEND NOTIFICATION TO SCRIPT/ZMQ
|
||||||
GetMainSignals().NotifyGovernanceObject(govobj);
|
GetMainSignals().NotifyGovernanceObject(govobj);
|
||||||
|
|
||||||
|
|
||||||
DBG(std::cout << "CGovernanceManager::AddGovernanceObject END" << std::endl;);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGovernanceManager::UpdateCachesAndClean()
|
void CGovernanceManager::UpdateCachesAndClean()
|
||||||
|
@ -5,8 +5,6 @@
|
|||||||
#ifndef GOVERNANCE_H
|
#ifndef GOVERNANCE_H
|
||||||
#define GOVERNANCE_H
|
#define GOVERNANCE_H
|
||||||
|
|
||||||
//#define ENABLE_DASH_DEBUG
|
|
||||||
|
|
||||||
#include "bloom.h"
|
#include "bloom.h"
|
||||||
#include "cachemap.h"
|
#include "cachemap.h"
|
||||||
#include "cachemultimap.h"
|
#include "cachemultimap.h"
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Distributed under the MIT/X11 software license, see the accompanying
|
// Distributed under the MIT/X11 software license, see the accompanying
|
||||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
//#define ENABLE_DASH_DEBUG
|
|
||||||
|
|
||||||
#include "activemasternode.h"
|
#include "activemasternode.h"
|
||||||
#include "consensus/validation.h"
|
#include "consensus/validation.h"
|
||||||
#include "governance.h"
|
#include "governance.h"
|
||||||
@ -225,11 +223,8 @@ UniValue gobject_prepare(const JSONRPCRequest& request)
|
|||||||
throw JSONRPCError(RPC_INTERNAL_ERROR, "CommitTransaction failed! Reason given: " + state.GetRejectReason());
|
throw JSONRPCError(RPC_INTERNAL_ERROR, "CommitTransaction failed! Reason given: " + state.GetRejectReason());
|
||||||
}
|
}
|
||||||
|
|
||||||
DBG( std::cout << "gobject: prepare "
|
LogPrint("gobject", "gobject_prepare -- GetDataAsPlainString = %s, hash = %s, txid = %s\n",
|
||||||
<< " GetDataAsPlainString = " << govobj.GetDataAsPlainString()
|
govobj.GetDataAsPlainString(), govobj.GetHash().ToString(), wtx.GetHash().ToString());
|
||||||
<< ", hash = " << govobj.GetHash().GetHex()
|
|
||||||
<< ", txidFee = " << wtx.GetHash().GetHex()
|
|
||||||
<< std::endl; );
|
|
||||||
|
|
||||||
return wtx.GetHash().ToString();
|
return wtx.GetHash().ToString();
|
||||||
}
|
}
|
||||||
@ -261,10 +256,9 @@ UniValue gobject_submit(const JSONRPCRequest& request)
|
|||||||
auto mnList = deterministicMNManager->GetListAtChainTip();
|
auto mnList = deterministicMNManager->GetListAtChainTip();
|
||||||
bool fMnFound = mnList.HasValidMNByCollateral(activeMasternodeInfo.outpoint);
|
bool fMnFound = mnList.HasValidMNByCollateral(activeMasternodeInfo.outpoint);
|
||||||
|
|
||||||
DBG( std::cout << "gobject: submit activeMasternodeInfo.pubKeyOperator = " << (activeMasternodeInfo.blsPubKeyOperator ? activeMasternodeInfo.blsPubKeyOperator->ToString() : "N/A")
|
LogPrint("gobject", "gobject_submit -- pubKeyOperator = %s, outpoint = %s, params.size() = %lld, fMnFound = %d\n",
|
||||||
<< ", outpoint = " << activeMasternodeInfo.outpoint.ToStringShort()
|
(activeMasternodeInfo.blsPubKeyOperator ? activeMasternodeInfo.blsPubKeyOperator->ToString() : "N/A"),
|
||||||
<< ", params.size() = " << request.params.size()
|
activeMasternodeInfo.outpoint.ToStringShort(), request.params.size(), fMnFound);
|
||||||
<< ", fMnFound = " << fMnFound << std::endl; );
|
|
||||||
|
|
||||||
// ASSEMBLE NEW GOVERNANCE OBJECT FROM USER PARAMETERS
|
// ASSEMBLE NEW GOVERNANCE OBJECT FROM USER PARAMETERS
|
||||||
|
|
||||||
@ -290,11 +284,8 @@ UniValue gobject_submit(const JSONRPCRequest& request)
|
|||||||
|
|
||||||
CGovernanceObject govobj(hashParent, nRevision, nTime, txidFee, strDataHex);
|
CGovernanceObject govobj(hashParent, nRevision, nTime, txidFee, strDataHex);
|
||||||
|
|
||||||
DBG( std::cout << "gobject: submit "
|
LogPrint("gobject", "gobject_submit -- GetDataAsPlainString = %s, hash = %s, txid = %s\n",
|
||||||
<< " GetDataAsPlainString = " << govobj.GetDataAsPlainString()
|
govobj.GetDataAsPlainString(), govobj.GetHash().ToString(), request.params[5].get_str());
|
||||||
<< ", hash = " << govobj.GetHash().GetHex()
|
|
||||||
<< ", txidFee = " << txidFee.GetHex()
|
|
||||||
<< std::endl; );
|
|
||||||
|
|
||||||
if (govobj.GetObjectType() == GOVERNANCE_OBJECT_PROPOSAL) {
|
if (govobj.GetObjectType() == GOVERNANCE_OBJECT_PROPOSAL) {
|
||||||
CProposalValidator validator(strDataHex, false);
|
CProposalValidator validator(strDataHex, false);
|
||||||
|
Loading…
Reference in New Issue
Block a user