Changeset View
Changeset View
Standalone View
Standalone View
src/net_processing.cpp
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
| Show First 20 Lines • Show All 2,019 Lines • ▼ Show 20 Lines | if (snap_base && state->pindexBestKnownBlock->GetAncestor( | ||||
| snap_base->nHeight) != snap_base) { | snap_base->nHeight) != snap_base) { | ||||
| LogDebug(BCLog::NET, | LogDebug(BCLog::NET, | ||||
| "Not downloading blocks from peer=%d, which doesn't have the " | "Not downloading blocks from peer=%d, which doesn't have the " | ||||
| "snapshot block in its best chain.\n", | "snapshot block in its best chain.\n", | ||||
| peer.m_id); | peer.m_id); | ||||
| return; | return; | ||||
| } | } | ||||
| if (state->pindexLastCommonBlock == nullptr) { | |||||
| // Bootstrap quickly by guessing a parent of our best tip is the forking | // Bootstrap quickly by guessing a parent of our best tip is the forking | ||||
| // point. Guessing wrong in either direction is not a problem. | // point. Guessing wrong in either direction is not a problem. Also reset | ||||
| // pindexLastCommonBlock after a snapshot was loaded, so that blocks after | |||||
| // the snapshot will be prioritised for download. | |||||
| if (state->pindexLastCommonBlock == nullptr || | |||||
| (snap_base && | |||||
| state->pindexLastCommonBlock->nHeight < snap_base->nHeight)) { | |||||
| state->pindexLastCommonBlock = | state->pindexLastCommonBlock = | ||||
| m_chainman | m_chainman | ||||
| .ActiveChain()[std::min(state->pindexBestKnownBlock->nHeight, | .ActiveChain()[std::min(state->pindexBestKnownBlock->nHeight, | ||||
| m_chainman.ActiveChain().Height())]; | m_chainman.ActiveChain().Height())]; | ||||
| } | } | ||||
| // If the peer reorganized, our previous pindexLastCommonBlock may not be an | // If the peer reorganized, our previous pindexLastCommonBlock may not be an | ||||
| // ancestor of its current tip anymore. Go back enough to fix that. | // ancestor of its current tip anymore. Go back enough to fix that. | ||||
| ▲ Show 20 Lines • Show All 7,287 Lines • Show Last 20 Lines | |||||