Skip to content

Commit

Permalink
ProcessSpecialTxsInBlock should respect fJustCheck (#2653)
Browse files Browse the repository at this point in the history
* ProcessSpecialTxsInBlock should respect fJustCheck

Also invoke it after subsidy/payee checks

* Drop fJustCheck from CQuorumBlockProcessor
  • Loading branch information
UdjinM6 authored and codablock committed Jan 29, 2019
1 parent 805aeaa commit 559bdfc
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
6 changes: 5 additions & 1 deletion src/evo/deterministicmns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ CDeterministicMNManager::CDeterministicMNManager(CEvoDB& _evoDb) :
{
}

bool CDeterministicMNManager::ProcessBlock(const CBlock& block, const CBlockIndex* pindex, CValidationState& _state)
bool CDeterministicMNManager::ProcessBlock(const CBlock& block, const CBlockIndex* pindex, CValidationState& _state, bool fJustCheck)
{
CDeterministicMNList oldList, newList;
CDeterministicMNListDiff diff;
Expand All @@ -458,6 +458,10 @@ bool CDeterministicMNManager::ProcessBlock(const CBlock& block, const CBlockInde
return false;
}

if (fJustCheck) {
return true;
}

if (newList.GetHeight() == -1) {
newList.SetHeight(nHeight);
}
Expand Down
2 changes: 1 addition & 1 deletion src/evo/deterministicmns.h
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ class CDeterministicMNManager
public:
CDeterministicMNManager(CEvoDB& _evoDb);

bool ProcessBlock(const CBlock& block, const CBlockIndex* pindex, CValidationState& state);
bool ProcessBlock(const CBlock& block, const CBlockIndex* pindex, CValidationState& state, bool fJustCheck);
bool UndoBlock(const CBlock& block, const CBlockIndex* pindex);

void UpdatedBlockTip(const CBlockIndex* pindex);
Expand Down
4 changes: 2 additions & 2 deletions src/evo/specialtx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ bool UndoSpecialTx(const CTransaction& tx, const CBlockIndex* pindex)
return false;
}

bool ProcessSpecialTxsInBlock(const CBlock& block, const CBlockIndex* pindex, CValidationState& state)
bool ProcessSpecialTxsInBlock(const CBlock& block, const CBlockIndex* pindex, CValidationState& state, bool fJustCheck)
{
for (int i = 0; i < (int)block.vtx.size(); i++) {
const CTransaction& tx = *block.vtx[i];
Expand All @@ -102,7 +102,7 @@ bool ProcessSpecialTxsInBlock(const CBlock& block, const CBlockIndex* pindex, CV
return false;
}

if (!deterministicMNManager->ProcessBlock(block, pindex, state)) {
if (!deterministicMNManager->ProcessBlock(block, pindex, state, fJustCheck)) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/evo/specialtx.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class CBlockIndex;
class CValidationState;

bool CheckSpecialTx(const CTransaction& tx, const CBlockIndex* pindexPrev, CValidationState& state);
bool ProcessSpecialTxsInBlock(const CBlock& block, const CBlockIndex* pindex, CValidationState& state);
bool ProcessSpecialTxsInBlock(const CBlock& block, const CBlockIndex* pindex, CValidationState& state, bool fJustCheck);
bool UndoSpecialTxsInBlock(const CBlock& block, const CBlockIndex* pindex);

template <typename T>
Expand Down
10 changes: 6 additions & 4 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2184,10 +2184,6 @@ static bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockInd
int64_t nTime4 = GetTimeMicros(); nTimeVerify += nTime4 - nTime2;
LogPrint("bench", " - Verify %u txins: %.2fms (%.3fms/txin) [%.2fs]\n", nInputs - 1, 0.001 * (nTime4 - nTime2), nInputs <= 1 ? 0 : 0.001 * (nTime4 - nTime2) / (nInputs-1), nTimeVerify * 0.000001);

if (!ProcessSpecialTxsInBlock(block, pindex, state)) {
return error("ConnectBlock(): ProcessSpecialTxsInBlock for block %s failed with %s",
pindex->GetBlockHash().ToString(), FormatStateMessage(state));
}

// DASH : MODIFIED TO CHECK MASTERNODE PAYMENTS AND SUPERBLOCKS

Expand All @@ -2208,6 +2204,12 @@ static bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockInd
return state.DoS(0, error("ConnectBlock(DASH): couldn't find masternode or superblock payments"),
REJECT_INVALID, "bad-cb-payee");
}

if (!ProcessSpecialTxsInBlock(block, pindex, state, fJustCheck)) {
return error("ConnectBlock(DASH): ProcessSpecialTxsInBlock for block %s failed with %s",
pindex->GetBlockHash().ToString(), FormatStateMessage(state));
}

int64_t nTime5 = GetTimeMicros(); nTimeVerify += nTime5 - nTime4;
LogPrint("bench", " - Payee and special txes: %.2fms [%.2fs]\n", 0.001 * (nTime4 - nTime2), nTimeVerify * 0.000001);

Expand Down

0 comments on commit 559bdfc

Please sign in to comment.