Browse Source

Add context flag to stop checking twice

z_createrawtransaction
blackjok3r 5 years ago
parent
commit
fa309e5b0e
  1. 5
      src/chain.h
  2. 20
      src/main.cpp

5
src/chain.h

@ -102,6 +102,9 @@ enum BlockStatus: uint32_t {
//! Scripts & signatures ok. Implies all parents are also at least SCRIPTS.
BLOCK_VALID_SCRIPTS = 5,
// flag to check if contextual check block has passed in Accept block, if it has not check at connect block.
BLOCK_VALID_CONTEXT = 6,
//! All validity bits.
BLOCK_VALID_MASK = BLOCK_VALID_HEADER | BLOCK_VALID_TREE | BLOCK_VALID_TRANSACTIONS |
BLOCK_VALID_CHAIN | BLOCK_VALID_SCRIPTS,
@ -115,7 +118,7 @@ enum BlockStatus: uint32_t {
BLOCK_FAILED_MASK = BLOCK_FAILED_VALID | BLOCK_FAILED_CHILD,
BLOCK_ACTIVATES_UPGRADE = 128, //! block activates a network upgrade
BLOCK_IN_TMPFILE = 256
BLOCK_IN_TMPFILE = 256
};
//! Short-hand for the highest consensus validity we implement.

20
src/main.cpp

@ -3274,14 +3274,17 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
//fprintf(stderr,"checkblock failure in connectblock futureblock.%d\n",futureblock);
return false;
}
// check pindex->CONTEXT_VALIDATED flag
if ( fCheckPOW != 0 && !ContextualCheckBlock(block, state, pindex->pprev) ) // Activate Jan 15th, 2019
if ( fCheckPOW != 0 && (pindex->nStatus & BLOCK_VALID_CONTEXT) != BLOCK_VALID_CONTEXT ) // Activate Jan 15th, 2019
{
fprintf(stderr,"ContextualCheckBlock failed ht.%d\n",(int32_t)pindex->GetHeight());
if ( pindex->nTime > 1547510400 )
return false;
fprintf(stderr,"grandfathered exception, until jan 15th 2019\n");
if ( !ContextualCheckBlock(block, state, pindex->pprev) )
{
fprintf(stderr,"ContextualCheckBlock failed ht.%d\n",(int32_t)pindex->GetHeight());
if ( pindex->nTime > 1547510400 )
return false;
fprintf(stderr,"grandfathered exception, until jan 15th 2019\n");
} else pindex->nStatus |= BLOCK_VALID_CONTEXT;
}
// Do this here before the block is moved to the main block files.
if ( ASSETCHAINS_NOTARY_PAY[0] != 0 && pindex->GetHeight() > 10 )
{
@ -5340,7 +5343,8 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C
// See method docstring for why this is always disabled
auto verifier = libzcash::ProofVerifier::Disabled();
if ((!CheckBlock(futureblockp,pindex->GetHeight(),pindex,block, state, verifier,0)) || !ContextualCheckBlock(block, state, pindex->pprev))
bool fContextualCheckBlock = ContextualCheckBlock(block, state, pindex->pprev);
if ( (!CheckBlock(futureblockp,pindex->GetHeight(),pindex,block, state, verifier,0)) || !fContextualCheckBlock )
{
static int32_t saplinght = -1;
CBlockIndex *tmpptr;
@ -5365,6 +5369,8 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C
return false;
}
}
if ( fContextualCheckBlock )
pindex->nStatus |= BLOCK_VALID_CONTEXT;
int nHeight = pindex->GetHeight();
// Temp File fix. LABS has been using this for ages with no bad effects.

Loading…
Cancel
Save