chain: add CChain::IsTipRecent helper

Factor the chain tip work/recency check out of `ChainstateManager::IsInitialBlockDownload()` into a reusable `CChain::IsTipRecent()` helper, and annotate it as requiring `cs_main` since it's reading mutable state.

Also introduce a local `chainman_ref` in the kernel import-blocks wrapper to reduce repetition and keep follow-up diffs small.

`IsInitialBlockDownload` returns were also unified to make the followup move clean.

Co-authored-by: Patrick Strateman <patrick.strateman@gmail.com>
Co-authored-by: Martin Zumsande <mzumsande@gmail.com>
This commit is contained in:
Lőrinc
2026-01-11 23:56:21 +01:00
parent 8d531c6210
commit b9c0ab3b75
3 changed files with 15 additions and 18 deletions

View File

@@ -1054,7 +1054,8 @@ int btck_chainstate_manager_import_blocks(btck_ChainstateManager* chainman, cons
import_files.emplace_back(std::string{block_file_paths_data[i], block_file_paths_lens[i]}.c_str());
}
}
node::ImportBlocks(*btck_ChainstateManager::get(chainman).m_chainman, import_files);
auto& chainman_ref{*btck_ChainstateManager::get(chainman).m_chainman};
node::ImportBlocks(chainman_ref, import_files);
} catch (const std::exception& e) {
LogError("Failed to import blocks: %s", e.what());
return -1;