Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename nEpochStart variable and adjust comments #1915

Merged
merged 3 commits into from
Feb 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions src/governance-classes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ void CGovernanceTriggerManager::CleanAndRemove()
case SEEN_OBJECT_IS_VALID:
case SEEN_OBJECT_EXECUTED:
{
int nTriggerBlock = pSuperblock->GetBlockStart();
int nTriggerBlock = pSuperblock->GetBlockHeight();
// Rough approximation: a cycle of superblock ++
int nExpirationBlock = nTriggerBlock + GOVERNANCE_TRIGGER_EXPIRATION_BLOCKS;
LogPrint("gobject", "CGovernanceTriggerManager::CleanAndRemove -- nTriggerBlock = %d, nExpirationBlock = %d\n", nTriggerBlock, nExpirationBlock);
Expand Down Expand Up @@ -312,13 +312,13 @@ bool CSuperblockManager::IsSuperblockTriggered(int nBlockHeight)

// note : 12.1 - is epoch calculation correct?

if(nBlockHeight != pSuperblock->GetBlockStart()) {
if(nBlockHeight != pSuperblock->GetBlockHeight()) {
LogPrint("gobject", "CSuperblockManager::IsSuperblockTriggered -- block height doesn't match nBlockHeight = %d, blockStart = %d, continuing\n",
nBlockHeight,
pSuperblock->GetBlockStart());
pSuperblock->GetBlockHeight());
DBG( cout << "IsSuperblockTriggered Not the target block, continuing"
<< ", nBlockHeight = " << nBlockHeight
<< ", superblock->GetBlockStart() = " << pSuperblock->GetBlockStart()
<< ", superblock->GetBlockHeight() = " << pSuperblock->GetBlockHeight()
<< endl; );
continue;
}
Expand Down Expand Up @@ -365,7 +365,7 @@ bool CSuperblockManager::GetBestSuperblock(CSuperblock_sptr& pSuperblockRet, int
continue;
}

if(nBlockHeight != pSuperblock->GetBlockStart()) {
if(nBlockHeight != pSuperblock->GetBlockHeight()) {
DBG( cout << "GetBestSuperblock Not the target block, continuing" << endl; );
continue;
}
Expand Down Expand Up @@ -463,15 +463,15 @@ bool CSuperblockManager::IsValid(const CTransaction& txNew, int nBlockHeight, CA
CSuperblock::
CSuperblock()
: nGovObjHash(),
nEpochStart(0),
nBlockHeight(0),
nStatus(SEEN_OBJECT_UNKNOWN),
vecPayments()
{}

CSuperblock::
CSuperblock(uint256& nHash)
: nGovObjHash(nHash),
nEpochStart(0),
nBlockHeight(0),
nStatus(SEEN_OBJECT_UNKNOWN),
vecPayments()
{
Expand All @@ -496,16 +496,16 @@ CSuperblock(uint256& nHash)

UniValue obj = pGovObj->GetJSONObject();

// FIRST WE GET THE START EPOCH, THE DATE WHICH THE PAYMENT SHALL OCCUR
nEpochStart = obj["event_block_height"].get_int();
// FIRST WE GET THE START HEIGHT, THE BLOCK HEIGHT AT WHICH THE PAYMENT SHALL OCCUR
nBlockHeight = 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();
ParsePaymentSchedule(strAddresses, strAmounts);

LogPrint("gobject", "CSuperblock -- nEpochStart = %d, strAddresses = %s, strAmounts = %s, vecPayments.size() = %d\n",
nEpochStart, strAddresses, strAmounts, vecPayments.size());
LogPrint("gobject", "CSuperblock -- nBlockHeight = %d, strAddresses = %s, strAmounts = %s, vecPayments.size() = %d\n",
nBlockHeight, strAddresses, strAmounts, vecPayments.size());

DBG( cout << "CSuperblock Constructor End" << endl; );
}
Expand Down
23 changes: 3 additions & 20 deletions src/governance-classes.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class CSuperblock : public CGovernanceObject
private:
uint256 nGovObjHash;

int nEpochStart;
int nBlockHeight;
int nStatus;
std::vector<CGovernancePayment> vecPayments;

Expand Down Expand Up @@ -177,26 +177,9 @@ class CSuperblock : public CGovernanceObject
return pObj;
}

int GetBlockStart()
int GetBlockHeight()
{
/* // 12.1 TRIGGER EXECUTION */
/* // NOTE : Is this over complicated? */

/* //int nRet = 0; */
/* int nTipEpoch = 0; */
/* int nTipBlock = chainActive.Tip()->nHeight+1; */

/* // GET TIP EPOCK / BLOCK */

/* // typically it should be more than the current time */
/* int nDiff = nEpochStart - nTipEpoch; */
/* int nBlockDiff = nDiff / (2.6*60); */

/* // calculate predicted block height */
/* int nMod = (nTipBlock + nBlockDiff) % Params().GetConsensus().nSuperblockCycle; */

/* return (nTipBlock + nBlockDiff)-nMod; */
return nEpochStart;
return nBlockHeight;
}

int CountPayments() { return (int)vecPayments.size(); }
Expand Down