interfaces, chain, refactor: Remove unused getTipLocator
What changed, and why it matters
This commit is a routine code cleanup. It removes an unused function called getTipLocator and a related internal helper, replacing one remaining use with an equivalent existing function. There is no security-relevant change.
No action needed. This is a benign refactor.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change removes the unused Chain::getTipLocator() interface method and CChain::GetLocator() implementation. The only remaining caller in validation.cpp is updated to use the equivalent GetLocator(m_chain.Tip()), which produces the same CBlockLocator result. This is a pure refactor with no behavioral or security impact.
Changed components
src/chain.cppsrc/chain.hsrc/interfaces/chain.hsrc/node/interfaces.cppsrc/validation.cppInspect captured patch +1 / −17
diff --git a/src/chain.cpp b/src/chain.cpp
index 82007a8a..4e2d1bf0 100644
--- a/src/chain.cpp
+++ b/src/chain.cpp
@@ -52,11 +52,6 @@ CBlockLocator GetLocator(const CBlockIndex* index)
return CBlockLocator{LocatorEntries(index)};
}
-CBlockLocator CChain::GetLocator() const
-{
- return ::GetLocator(Tip());
-}
-
const CBlockIndex *CChain::FindFork(const CBlockIndex *pindex) const {
if (pindex == nullptr) {
return nullptr;
diff --git a/src/chain.h b/src/chain.h
index f5bfdb2f..68aa612b 100644
--- a/src/chain.h
+++ b/src/chain.h
@@ -467,9 +467,6 @@ public:
/** Set/initialize a chain with a given tip. */
void SetTip(CBlockIndex& block);
- /** Return a CBlockLocator that refers to the tip in of this chain. */
- CBlockLocator GetLocator() const;
-
/** Find the last common block between this chain and a block index entry. */
const CBlockIndex* FindFork(const CBlockIndex* pindex) const;
diff --git a/src/interfaces/chain.h b/src/interfaces/chain.h
index 56716ec6..f45cb8e5 100644
--- a/src/interfaces/chain.h
+++ b/src/interfaces/chain.h
@@ -143,9 +143,6 @@ public:
//! pruned), and contains transactions.
virtual bool haveBlockOnDisk(int height) = 0;
- //! Get locator for the current chain tip.
- virtual CBlockLocator getTipLocator() = 0;
-
//! Return a locator that refers to a block in the active chain.
//! If specified block is not in the active chain, return locator for the latest ancestor that is in the chain.
virtual CBlockLocator getActiveChainLocator(const uint256& block_hash) = 0;
diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp
index 62172930..d7ada5ae 100644
--- a/src/node/interfaces.cpp
+++ b/src/node/interfaces.cpp
@@ -559,11 +559,6 @@ public:
const CBlockIndex* block{chainman().ActiveChain()[height]};
return block && ((block->nStatus & BLOCK_HAVE_DATA) != 0) && block->nTx > 0;
}
- CBlockLocator getTipLocator() override
- {
- LOCK(::cs_main);
- return chainman().ActiveChain().GetLocator();
- }
CBlockLocator getActiveChainLocator(const uint256& block_hash) override
{
LOCK(::cs_main);
diff --git a/src/validation.cpp b/src/validation.cpp
index 61dec131..fbc1b03c 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -2919,7 +2919,7 @@ bool Chainstate::FlushStateToDisk(
}
if (full_flush_completed && m_chainman.m_options.signals) {
// Update best block in wallet (so we can detect restored wallets).
- m_chainman.m_options.signals->ChainStateFlushed(this->GetRole(), m_chain.GetLocator());
+ m_chainman.m_options.signals->ChainStateFlushed(this->GetRole(), GetLocator(m_chain.Tip()));
}
} catch (const std::runtime_error& e) {
return FatalError(m_chainman.GetNotifications(), state, strprintf(_("System error while flushing: %s"), e.what()));
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.