Better way to avoid sync errors
This commit is contained in:
16
src/main.cpp
16
src/main.cpp
@@ -512,8 +512,8 @@ namespace {
|
||||
// Never fetch further than the best block we know the peer has, or more than BLOCK_DOWNLOAD_WINDOW + 1 beyond the last
|
||||
// linked block we have in common with this peer. The +1 is so we can detect stalling, namely if we would be able to
|
||||
// download that next block if the window were 1 larger.
|
||||
if ( ASSETCHAINS_CBOPRET != 0 )
|
||||
BLOCK_DOWNLOAD_WINDOW = 1;
|
||||
//if ( ASSETCHAINS_CBOPRET != 0 )
|
||||
// BLOCK_DOWNLOAD_WINDOW = 1;
|
||||
int nWindowEnd = state->pindexLastCommonBlock->GetHeight() + BLOCK_DOWNLOAD_WINDOW;
|
||||
int nMaxHeight = std::min<int>(state->pindexBestKnownBlock->GetHeight(), nWindowEnd + 1);
|
||||
NodeId waitingfor = -1;
|
||||
@@ -980,7 +980,7 @@ unsigned int GetP2SHSigOpCount(const CTransaction& tx, const CCoinsViewCache& in
|
||||
* Ensure that a coinbase transaction is structured according to the consensus rules of the
|
||||
* chain
|
||||
*/
|
||||
bool ContextualCheckCoinbaseTransaction(const CBlock *block,CBlockIndex * const previndex,const CTransaction& tx, const int nHeight)
|
||||
bool ContextualCheckCoinbaseTransaction(const CBlock *block,CBlockIndex * const previndex,const CTransaction& tx, const int nHeight,int32_t validateprices)
|
||||
{
|
||||
// if time locks are on, ensure that this coin base is time locked exactly as it should be
|
||||
if (((uint64_t)(tx.GetValueOut()) >= ASSETCHAINS_TIMELOCKGTE) ||
|
||||
@@ -1021,7 +1021,7 @@ bool ContextualCheckCoinbaseTransaction(const CBlock *block,CBlockIndex * const
|
||||
{
|
||||
|
||||
}
|
||||
else if ( ASSETCHAINS_CBOPRET != 0 && nHeight > 0 && tx.vout.size() > 0 )
|
||||
else if ( ASSETCHAINS_CBOPRET != 0 && validateprices != 0 && nHeight > 0 && tx.vout.size() > 0 )
|
||||
{
|
||||
if ( komodo_opretvalidate(block,previndex,nHeight,tx.vout[tx.vout.size()-1].scriptPubKey) < 0 )
|
||||
return(false);
|
||||
@@ -1043,7 +1043,7 @@ bool ContextualCheckTransaction(const CBlock *block, CBlockIndex * const prevind
|
||||
CValidationState &state,
|
||||
const int nHeight,
|
||||
const int dosLevel,
|
||||
bool (*isInitBlockDownload)())
|
||||
bool (*isInitBlockDownload)(),int32_t validateprices)
|
||||
{
|
||||
bool overwinterActive = NetworkUpgradeActive(nHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER);
|
||||
bool saplingActive = NetworkUpgradeActive(nHeight, Params().GetConsensus(), Consensus::UPGRADE_SAPLING);
|
||||
@@ -1174,7 +1174,7 @@ bool ContextualCheckTransaction(const CBlock *block, CBlockIndex * const prevind
|
||||
|
||||
if (tx.IsCoinBase())
|
||||
{
|
||||
if (!ContextualCheckCoinbaseTransaction(block,previndex,tx, nHeight))
|
||||
if (!ContextualCheckCoinbaseTransaction(block,previndex,tx, nHeight,validateprices))
|
||||
return state.DoS(100, error("CheckTransaction(): invalid script data for coinbase time lock"),
|
||||
REJECT_INVALID, "bad-txns-invalid-script-data-for-coinbase-time-lock");
|
||||
}
|
||||
@@ -1679,7 +1679,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
|
||||
}
|
||||
// DoS level set to 10 to be more forgiving.
|
||||
// Check transaction contextually against the set of consensus rules which apply in the next block to be mined.
|
||||
if (!fSkipExpiry && !ContextualCheckTransaction(0,0,tx, state, nextBlockHeight, (dosLevel == -1) ? 10 : dosLevel))
|
||||
if (!fSkipExpiry && !ContextualCheckTransaction(0,0,tx, state, nextBlockHeight, (dosLevel == -1) ? 10 : dosLevel,0))
|
||||
{
|
||||
return error("AcceptToMemoryPool: ContextualCheckTransaction failed");
|
||||
}
|
||||
@@ -5151,7 +5151,7 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn
|
||||
const CTransaction& tx = block.vtx[i];
|
||||
|
||||
// Check transaction contextually against consensus rules at block height
|
||||
if (!ContextualCheckTransaction(&block,pindexPrev,tx, state, nHeight, 100)) {
|
||||
if (!ContextualCheckTransaction(&block,pindexPrev,tx, state, nHeight, 100,1)) {
|
||||
return false; // Failure reason has been set in validation state object
|
||||
}
|
||||
|
||||
|
||||
@@ -707,7 +707,7 @@ bool ContextualCheckInputs(const CTransaction& tx, CValidationState &state, cons
|
||||
|
||||
/** Check a transaction contextually against a set of consensus rules */
|
||||
bool ContextualCheckTransaction(const CBlock *block, CBlockIndex * const pindexPrev,const CTransaction& tx, CValidationState &state, int nHeight, int dosLevel,
|
||||
bool (*isInitBlockDownload)() = IsInitialBlockDownload);
|
||||
bool (*isInitBlockDownload)() = IsInitialBlockDownload,int32_t validateprices);
|
||||
|
||||
/** Apply the effects of this transaction on the UTXO set represented by view */
|
||||
void UpdateCoins(const CTransaction& tx, CCoinsViewCache& inputs, int nHeight);
|
||||
|
||||
Reference in New Issue
Block a user