Merge pull request #1394 from blackjok3rtt/dpow_test

Dpow test
This commit is contained in:
jl777
2019-04-11 00:30:50 -11:00
committed by GitHub
2 changed files with 31 additions and 32 deletions

View File

@@ -691,7 +691,7 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar
else else
{ {
komodo_rwccdata(ASSETCHAINS_SYMBOL,1,&ccdata,&MoMoMdata); komodo_rwccdata(ASSETCHAINS_SYMBOL,1,&ccdata,&MoMoMdata);
if ( !fJustCheck && matched != 0 ) if ( matched != 0 )
printf("[%s] matched.%d VALID (%s) MoM.%s [%d] CCid.%u\n",ASSETCHAINS_SYMBOL,matched,ccdata.symbol,MoM.ToString().c_str(),MoMdepth&0xffff,(MoMdepth>>16)&0xffff); printf("[%s] matched.%d VALID (%s) MoM.%s [%d] CCid.%u\n",ASSETCHAINS_SYMBOL,matched,ccdata.symbol,MoM.ToString().c_str(),MoMdepth&0xffff,(MoMdepth>>16)&0xffff);
} }
if ( MoMoMdata.pairs != 0 ) if ( MoMoMdata.pairs != 0 )
@@ -747,7 +747,7 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar
} }
else if ( matched != 0 && i == 0 && j == 1 && opretlen == 149 ) else if ( matched != 0 && i == 0 && j == 1 && opretlen == 149 )
{ {
if ( !fJustCheck && notaryid >= 0 && notaryid < 64 ) if ( notaryid >= 0 && notaryid < 64 )
komodo_paxpricefeed(height,&scriptbuf[len],opretlen); komodo_paxpricefeed(height,&scriptbuf[len],opretlen);
} }
else if ( matched != 0 ) else if ( matched != 0 )

View File

@@ -4235,6 +4235,15 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo
const CBlockIndex *pindexOldTip = chainActive.Tip(); const CBlockIndex *pindexOldTip = chainActive.Tip();
const CBlockIndex *pindexFork = chainActive.FindFork(pindexMostWork); const CBlockIndex *pindexFork = chainActive.FindFork(pindexMostWork);
// stop trying to reorg if the reorged chain is before last notarized height.
// stay on the same chain tip!
int32_t notarizedht,prevMoMheight; uint256 notarizedhash,txid;
notarizedht = komodo_notarized_height(&prevMoMheight,&notarizedhash,&txid);
if ( pindexFork->GetHeight() < notarizedht )
{
fprintf(stderr,"pindexFork->GetHeight().%d is < notarizedht %d, so ignore it\n",(int32_t)pindexFork->GetHeight(),notarizedht);
return false;
}
// - On ChainDB initialization, pindexOldTip will be null, so there are no removable blocks. // - On ChainDB initialization, pindexOldTip will be null, so there are no removable blocks.
// - If pindexMostWork is in a chain that doesn't have the same genesis block as our chain, // - If pindexMostWork is in a chain that doesn't have the same genesis block as our chain,
// then pindexFork will be null, and we would need to remove the entire chain including // then pindexFork will be null, and we would need to remove the entire chain including
@@ -4242,15 +4251,6 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo
auto reorgLength = pindexOldTip ? pindexOldTip->GetHeight() - (pindexFork ? pindexFork->GetHeight() : -1) : 0; auto reorgLength = pindexOldTip ? pindexOldTip->GetHeight() - (pindexFork ? pindexFork->GetHeight() : -1) : 0;
assert(MAX_REORG_LENGTH > 0);//, "We must be able to reorg some distance"); assert(MAX_REORG_LENGTH > 0);//, "We must be able to reorg some distance");
if ( reorgLength > MAX_REORG_LENGTH) if ( reorgLength > MAX_REORG_LENGTH)
{
int32_t notarizedht,prevMoMheight; uint256 notarizedhash,txid;
notarizedht = komodo_notarized_height(&prevMoMheight,&notarizedhash,&txid);
if ( pindexFork->GetHeight() < notarizedht )
{
fprintf(stderr,"pindexFork->GetHeight().%d is < notarizedht %d, so ignore it\n",(int32_t)pindexFork->GetHeight(),notarizedht);
pindexFork = pindexOldTip;
}
else
{ {
auto msg = strprintf(_( auto msg = strprintf(_(
"A block chain reorganization has been detected that would roll back %d blocks! " "A block chain reorganization has been detected that would roll back %d blocks! "
@@ -4272,7 +4272,6 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo
StartShutdown(); StartShutdown();
return false; return false;
} }
}
// Disconnect active blocks which are no longer in the best chain. // Disconnect active blocks which are no longer in the best chain.
bool fBlocksDisconnected = false; bool fBlocksDisconnected = false;