Merge pull request #1400 from blackjok3rtt/jl777
fix bug with dpow update
This commit is contained in:
@@ -1886,7 +1886,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
uiInterface.InitMessage(_("Activating best chain..."));
|
uiInterface.InitMessage(_("Activating best chain..."));
|
||||||
// scan for better chains in the block chain database, that are not yet connected in the active best chain
|
// scan for better chains in the block chain database, that are not yet connected in the active best chain
|
||||||
CValidationState state;
|
CValidationState state;
|
||||||
if ( !ActivateBestChain(state))
|
if ( !ActivateBestChain(true,state))
|
||||||
strErrors << "Failed to connect best block";
|
strErrors << "Failed to connect best block";
|
||||||
}
|
}
|
||||||
std::vector<boost::filesystem::path> vImportFiles;
|
std::vector<boost::filesystem::path> vImportFiles;
|
||||||
|
|||||||
12
src/main.cpp
12
src/main.cpp
@@ -4231,7 +4231,7 @@ static void PruneBlockIndexCandidates() {
|
|||||||
* Try to make some progress towards making pindexMostWork the active block.
|
* Try to make some progress towards making pindexMostWork the active block.
|
||||||
* pblock is either NULL or a pointer to a CBlock corresponding to pindexMostWork.
|
* pblock is either NULL or a pointer to a CBlock corresponding to pindexMostWork.
|
||||||
*/
|
*/
|
||||||
static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMostWork, CBlock *pblock) {
|
static bool ActivateBestChainStep(bool fSkipdpow, CValidationState &state, CBlockIndex *pindexMostWork, CBlock *pblock) {
|
||||||
AssertLockHeld(cs_main);
|
AssertLockHeld(cs_main);
|
||||||
bool fInvalidFound = false;
|
bool fInvalidFound = false;
|
||||||
const CBlockIndex *pindexOldTip = chainActive.Tip();
|
const CBlockIndex *pindexOldTip = chainActive.Tip();
|
||||||
@@ -4241,7 +4241,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo
|
|||||||
// stay on the same chain tip!
|
// stay on the same chain tip!
|
||||||
int32_t notarizedht,prevMoMheight; uint256 notarizedhash,txid;
|
int32_t notarizedht,prevMoMheight; uint256 notarizedhash,txid;
|
||||||
notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid);
|
notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid);
|
||||||
if ( pindexFork != 0 && pindexFork->GetHeight() < notarizedht )
|
if ( !fSkipdpow && pindexFork != 0 && pindexFork->GetHeight() < notarizedht )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"pindexFork->GetHeight().%d is < notarizedht %d, so ignore it\n",(int32_t)pindexFork->GetHeight(),notarizedht);
|
fprintf(stderr,"pindexFork->GetHeight().%d is < notarizedht %d, so ignore it\n",(int32_t)pindexFork->GetHeight(),notarizedht);
|
||||||
return state.DoS(100, error("ActivateBestChainStep(): pindexFork->GetHeight().%d is < notarizedht %d, so ignore it",(int32_t)pindexFork->GetHeight(),notarizedht),
|
return state.DoS(100, error("ActivateBestChainStep(): pindexFork->GetHeight().%d is < notarizedht %d, so ignore it",(int32_t)pindexFork->GetHeight(),notarizedht),
|
||||||
@@ -4366,7 +4366,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo
|
|||||||
* or an activated best chain. pblock is either NULL or a pointer to a block
|
* or an activated best chain. pblock is either NULL or a pointer to a block
|
||||||
* that is already loaded (to avoid loading it again from disk).
|
* that is already loaded (to avoid loading it again from disk).
|
||||||
*/
|
*/
|
||||||
bool ActivateBestChain(CValidationState &state, CBlock *pblock) {
|
bool ActivateBestChain(bool fSkipdpow, CValidationState &state, CBlock *pblock) {
|
||||||
CBlockIndex *pindexNewTip = NULL;
|
CBlockIndex *pindexNewTip = NULL;
|
||||||
CBlockIndex *pindexMostWork = NULL;
|
CBlockIndex *pindexMostWork = NULL;
|
||||||
const CChainParams& chainParams = Params();
|
const CChainParams& chainParams = Params();
|
||||||
@@ -4382,7 +4382,7 @@ bool ActivateBestChain(CValidationState &state, CBlock *pblock) {
|
|||||||
if (pindexMostWork == NULL || pindexMostWork == chainActive.Tip())
|
if (pindexMostWork == NULL || pindexMostWork == chainActive.Tip())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (!ActivateBestChainStep(state, pindexMostWork, pblock && pblock->GetHash() == pindexMostWork->GetBlockHash() ? pblock : NULL))
|
if (!ActivateBestChainStep(fSkipdpow, state, pindexMostWork, pblock && pblock->GetHash() == pindexMostWork->GetBlockHash() ? pblock : NULL))
|
||||||
return false;
|
return false;
|
||||||
pindexNewTip = chainActive.Tip();
|
pindexNewTip = chainActive.Tip();
|
||||||
fInitialDownload = IsInitialBlockDownload();
|
fInitialDownload = IsInitialBlockDownload();
|
||||||
@@ -5542,7 +5542,7 @@ bool ProcessNewBlock(bool from_miner,int32_t height,CValidationState &state, CNo
|
|||||||
//else fprintf(stderr,"added block %s %p\n",pindex->GetBlockHash().ToString().c_str(),pindex->pprev);
|
//else fprintf(stderr,"added block %s %p\n",pindex->GetBlockHash().ToString().c_str(),pindex->pprev);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (futureblock == 0 && !ActivateBestChain(state, pblock))
|
if (futureblock == 0 && !ActivateBestChain(false, state, pblock))
|
||||||
return error("%s: ActivateBestChain failed", __func__);
|
return error("%s: ActivateBestChain failed", __func__);
|
||||||
//fprintf(stderr,"finished ProcessBlock %d\n",(int32_t)chainActive.LastTip()->GetHeight());
|
//fprintf(stderr,"finished ProcessBlock %d\n",(int32_t)chainActive.LastTip()->GetHeight());
|
||||||
|
|
||||||
@@ -6319,7 +6319,7 @@ bool InitBlockIndex() {
|
|||||||
return error("LoadBlockIndex(): couldnt add to block index");
|
return error("LoadBlockIndex(): couldnt add to block index");
|
||||||
if (!ReceivedBlockTransactions(block, state, pindex, blockPos))
|
if (!ReceivedBlockTransactions(block, state, pindex, blockPos))
|
||||||
return error("LoadBlockIndex(): genesis block not accepted");
|
return error("LoadBlockIndex(): genesis block not accepted");
|
||||||
if (!ActivateBestChain(state, &block))
|
if (!ActivateBestChain(true, state, &block))
|
||||||
return error("LoadBlockIndex(): genesis block cannot be activated");
|
return error("LoadBlockIndex(): genesis block cannot be activated");
|
||||||
// Force a chainstate write so that when we VerifyDB in a moment, it doesn't check stale data
|
// Force a chainstate write so that when we VerifyDB in a moment, it doesn't check stale data
|
||||||
return FlushStateToDisk(state, FLUSH_STATE_ALWAYS);
|
return FlushStateToDisk(state, FLUSH_STATE_ALWAYS);
|
||||||
|
|||||||
@@ -252,7 +252,7 @@ std::string GetWarnings(const std::string& strFor);
|
|||||||
/** Retrieve a transaction (from memory pool, or from disk, if possible) */
|
/** Retrieve a transaction (from memory pool, or from disk, if possible) */
|
||||||
bool GetTransaction(const uint256 &hash, CTransaction &tx, uint256 &hashBlock, bool fAllowSlow = false);
|
bool GetTransaction(const uint256 &hash, CTransaction &tx, uint256 &hashBlock, bool fAllowSlow = false);
|
||||||
/** Find the best known block, and make it the tip of the block chain */
|
/** Find the best known block, and make it the tip of the block chain */
|
||||||
bool ActivateBestChain(CValidationState &state, CBlock *pblock = NULL);
|
bool ActivateBestChain(bool fSkipdpow, CValidationState &state, CBlock *pblock = NULL);
|
||||||
CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams);
|
CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1879,7 +1879,7 @@ UniValue invalidateblock(const UniValue& params, bool fHelp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (state.IsValid()) {
|
if (state.IsValid()) {
|
||||||
ActivateBestChain(state);
|
ActivateBestChain(true,state);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!state.IsValid()) {
|
if (!state.IsValid()) {
|
||||||
@@ -1918,7 +1918,7 @@ UniValue reconsiderblock(const UniValue& params, bool fHelp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (state.IsValid()) {
|
if (state.IsValid()) {
|
||||||
ActivateBestChain(state);
|
ActivateBestChain(true,state);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!state.IsValid()) {
|
if (!state.IsValid()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user