disable block cache / fix reprocess

This commit is contained in:
Evan Duffield 2015-08-01 01:51:30 -07:00
parent 8b62e590df
commit 44c99417d2
3 changed files with 20 additions and 27 deletions

View File

@ -3106,15 +3106,17 @@ bool AcceptBlockHeader(const CBlockHeader& block, CValidationState& state, CBloc
uint256 hash = block.GetHash();
BlockMap::iterator miSelf = mapBlockIndex.find(hash);
CBlockIndex *pindex = NULL;
if (miSelf != mapBlockIndex.end()) {
// Block header is already known.
pindex = miSelf->second;
if (ppindex)
*ppindex = pindex;
if (pindex->nStatus & BLOCK_FAILED_MASK)
return state.Invalid(error("%s : block is marked invalid", __func__), 0, "duplicate");
return true;
}
// TODO : ENABLE BLOCK CACHE IN SPECIFIC CASES
// if (miSelf != mapBlockIndex.end()) {
// // Block header is already known.
// pindex = miSelf->second;
// if (ppindex)
// *ppindex = pindex;
// if (pindex->nStatus & BLOCK_FAILED_MASK)
// return state.Invalid(error("%s : block is marked invalid", __func__), 0, "duplicate");
// return true;
// }
if (!CheckBlockHeader(block, state))
return false;

View File

@ -209,6 +209,8 @@ std::string GetWarnings(std::string strFor);
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 */
bool DisconnectBlocksAndReprocess(int blocks);
// ***TODO***
double ConvertBitsToDouble(unsigned int nBits);
int64_t GetMasternodePayment(int nHeight, int64_t blockValue);

View File

@ -134,27 +134,16 @@ void ExecuteSpork(int nSporkID, int nValue)
//correct fork via spork technology
if(nSporkID == SPORK_12_RECONSIDER_BLOCKS && nValue > 0) {
LogPrintf("Spork::ExecuteSpork -- Reconcider Last %d Blocks\n", nValue);
CBlockIndex* pindexPrev = chainActive.Tip();
int count = 0;
for (unsigned int i = 1; pindexPrev && pindexPrev->nHeight > 0; i++) {
count++;
if(count >= nValue) return;
CValidationState state;
{
LOCK(cs_main);
CValidationState state;
{
LOCK(cs_main);
DisconnectBlocksAndReprocess(nValue);
}
LogPrintf("Spork::ExecuteSpork -- Reconcider %s\n", pindexPrev->phashBlock->ToString());
ReconsiderBlock(state, pindexPrev);
}
if (state.IsValid()) {
ActivateBestChain(state);
}
if (pindexPrev->pprev == NULL) { assert(pindexPrev); break; }
pindexPrev = pindexPrev->pprev;
if (state.IsValid()) {
ActivateBestChain(state);
}
}
}