Remove option to load new blocks from ConnectTip
This commit is contained in:
parent
caea54013e
commit
2013b35e3e
20
src/main.cpp
20
src/main.cpp
|
@ -3212,15 +3212,9 @@ uint64_t nNotifiedSequence = 0;
|
||||||
*/
|
*/
|
||||||
bool static ConnectTip(CValidationState& state, const CChainParams& chainparams, CBlockIndex* pindexNew, const CBlock* pblock)
|
bool static ConnectTip(CValidationState& state, const CChainParams& chainparams, CBlockIndex* pindexNew, const CBlock* pblock)
|
||||||
{
|
{
|
||||||
assert(pindexNew->pprev == chainActive.Tip());
|
assert(pblock && pindexNew->pprev == chainActive.Tip());
|
||||||
// Read block from disk.
|
// Read block from disk.
|
||||||
int64_t nTime1 = GetTimeMicros();
|
int64_t nTime1 = GetTimeMicros();
|
||||||
CBlock block;
|
|
||||||
if (!pblock) {
|
|
||||||
if (!ReadBlockFromDisk(block, pindexNew, chainparams.GetConsensus()))
|
|
||||||
return AbortNode(state, "Failed to read block");
|
|
||||||
pblock = █
|
|
||||||
}
|
|
||||||
// Apply the block atomically to the chain state.
|
// Apply the block atomically to the chain state.
|
||||||
int64_t nTime2 = GetTimeMicros(); nTimeReadFromDisk += nTime2 - nTime1;
|
int64_t nTime2 = GetTimeMicros(); nTimeReadFromDisk += nTime2 - nTime1;
|
||||||
int64_t nTime3;
|
int64_t nTime3;
|
||||||
|
@ -3431,7 +3425,17 @@ static bool ActivateBestChainStep(CValidationState& state, const CChainParams& c
|
||||||
|
|
||||||
// Connect new blocks.
|
// Connect new blocks.
|
||||||
BOOST_REVERSE_FOREACH(CBlockIndex *pindexConnect, vpindexToConnect) {
|
BOOST_REVERSE_FOREACH(CBlockIndex *pindexConnect, vpindexToConnect) {
|
||||||
if (!ConnectTip(state, chainparams, pindexConnect, pindexConnect == pindexMostWork ? pblock : NULL)) {
|
const CBlock* pconnectBlock = pblock;
|
||||||
|
CBlock block;
|
||||||
|
if (pindexConnect != pindexMostWork) {
|
||||||
|
if (!ReadBlockFromDisk(block, pindexConnect, chainparams.GetConsensus()))
|
||||||
|
return AbortNode(state, "Failed to read block");
|
||||||
|
pconnectBlock = █
|
||||||
|
} else {
|
||||||
|
pconnectBlock = pblock;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ConnectTip(state, chainparams, pindexConnect, pconnectBlock)) {
|
||||||
if (state.IsInvalid()) {
|
if (state.IsInvalid()) {
|
||||||
// The block violates a consensus rule.
|
// The block violates a consensus rule.
|
||||||
if (!state.CorruptionPossible())
|
if (!state.CorruptionPossible())
|
||||||
|
|
Loading…
Reference in New Issue