| 294 | } |
| 295 | |
| 296 | CBlockLocator HeadersSyncState::NextHeadersRequestLocator() const |
| 297 | { |
| 298 | Assume(m_download_state != State::FINAL); |
| 299 | if (m_download_state == State::FINAL) return {}; |
| 300 | |
| 301 | auto chain_start_locator = LocatorEntries(&m_chain_start); |
| 302 | std::vector<uint256> locator; |
| 303 | |
| 304 | if (m_download_state == State::PRESYNC) { |
| 305 | // During pre-synchronization, we continue from the last header received. |
| 306 | locator.push_back(m_last_header_received.GetHash()); |
| 307 | } |
| 308 | |
| 309 | if (m_download_state == State::REDOWNLOAD) { |
| 310 | // During redownload, we will download from the last received header that we stored. |
| 311 | locator.push_back(m_redownload_buffer_last_hash); |
| 312 | } |
| 313 | |
| 314 | locator.insert(locator.end(), chain_start_locator.begin(), chain_start_locator.end()); |
| 315 | |
| 316 | return CBlockLocator{std::move(locator)}; |
| 317 | } |