What changed, and why it matters
This commit is a straightforward code-quality change: it adds the word 'const' to a notification callback parameter so subscribers receive a read-only view of the current block tip index. It does not fix a bug, close a vulnerability, or change any behavior. It simply prevents future implementations of the callback from accidentally modifying the index.
No security action needed. Treat as a normal defensive-coding / API-hardening refactor.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change makes the CBlockIndex& parameter of kernel::Notifications::blockTip and its overrides const (const CBlockIndex&). This enforces at compile time that notification subscribers cannot mutate the block index. The implementation in node::KernelNotifications::blockTip only reads from the index (it stores the block hash under a lock), so the change is compatible and non-breaking. No logic, locking, or data flow is altered.
Changed components
src/kernel/notifications_interface.hsrc/node/kernel_notifications.hsrc/node/kernel_notifications.cppsrc/bitcoin-chainstate.cppInspect captured patch +4 / −4
diff --git a/src/bitcoin-chainstate.cpp b/src/bitcoin-chainstate.cpp
index 4ac6a6f4..46e6f06e 100644
--- a/src/bitcoin-chainstate.cpp
+++ b/src/bitcoin-chainstate.cpp
@@ -74,7 +74,7 @@ int main(int argc, char* argv[])
class KernelNotifications : public kernel::Notifications
{
public:
- kernel::InterruptResult blockTip(SynchronizationState, CBlockIndex&, double) override
+ kernel::InterruptResult blockTip(SynchronizationState, const CBlockIndex&, double) override
{
std::cout << "Block tip changed" << std::endl;
return {};
diff --git a/src/kernel/notifications_interface.h b/src/kernel/notifications_interface.h
index 3e97e3b4..816f0630 100644
--- a/src/kernel/notifications_interface.h
+++ b/src/kernel/notifications_interface.h
@@ -37,7 +37,7 @@ class Notifications
public:
virtual ~Notifications() = default;
- [[nodiscard]] virtual InterruptResult blockTip(SynchronizationState state, CBlockIndex& index, double verification_progress) { return {}; }
+ [[nodiscard]] virtual InterruptResult blockTip(SynchronizationState state, const CBlockIndex& index, double verification_progress) { return {}; }
virtual void headerTip(SynchronizationState state, int64_t height, int64_t timestamp, bool presync) {}
virtual void progress(const bilingual_str& title, int progress_percent, bool resume_possible) {}
virtual void warningSet(Warning id, const bilingual_str& message) {}
diff --git a/src/node/kernel_notifications.cpp b/src/node/kernel_notifications.cpp
index 4a6f8444..56c7188a 100644
--- a/src/node/kernel_notifications.cpp
+++ b/src/node/kernel_notifications.cpp
@@ -48,7 +48,7 @@ static void AlertNotify(const std::string& strMessage)
namespace node {
-kernel::InterruptResult KernelNotifications::blockTip(SynchronizationState state, CBlockIndex& index, double verification_progress)
+kernel::InterruptResult KernelNotifications::blockTip(SynchronizationState state, const CBlockIndex& index, double verification_progress)
{
{
LOCK(m_tip_block_mutex);
diff --git a/src/node/kernel_notifications.h b/src/node/kernel_notifications.h
index 10ee3e18..21d2ea43 100644
--- a/src/node/kernel_notifications.h
+++ b/src/node/kernel_notifications.h
@@ -35,7 +35,7 @@ public:
KernelNotifications(const std::function<bool()>& shutdown_request, std::atomic<int>& exit_status, node::Warnings& warnings)
: m_shutdown_request(shutdown_request), m_exit_status{exit_status}, m_warnings{warnings} {}
- [[nodiscard]] kernel::InterruptResult blockTip(SynchronizationState state, CBlockIndex& index, double verification_progress) override EXCLUSIVE_LOCKS_REQUIRED(!m_tip_block_mutex);
+ [[nodiscard]] kernel::InterruptResult blockTip(SynchronizationState state, const CBlockIndex& index, double verification_progress) override EXCLUSIVE_LOCKS_REQUIRED(!m_tip_block_mutex);
void headerTip(SynchronizationState state, int64_t height, int64_t timestamp, bool presync) override;
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.