Skip to content

Commit e416dc2

Browse files
committed
Merge bitcoin/bitcoin#33321: kernel: make blockTip index const
75d9b72 kernel: make blockTip index const (stickies-v) Pull request description: Notification interface subscribers need to view, but not mutate, the index. This change allows improving the #30595 kernel interface, see e.g. `BlockTreeEntry` where [currently](https://github.com/bitcoin/bitcoin/pull/30595/files#diff-4d05cd02fdce641be603f0f9abcecfeaf76944285d4539ba4bbc40337fa9bbc2R617) a `View` is constructed from a non-const pointer, whereas really this should be a `const btck_BlockTreeEntry* entry`. ACKs for top commit: achow101: ACK 75d9b72 TheCharlatan: ACK 75d9b72 l0rinc: Code review ACK 75d9b72 yuvicc: Code review ACK 75d9b72 Tree-SHA512: 6151374a040cead36490c5fa5ce9dc4d93499a02110f444c50bd90f9095912747bc5b2fd7294815e6794c96a6843f43eb0507706d41d7296af96071b5f704ff4
2 parents 176fac0 + 75d9b72 commit e416dc2

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

src/bitcoin-chainstate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ int main(int argc, char* argv[])
7474
class KernelNotifications : public kernel::Notifications
7575
{
7676
public:
77-
kernel::InterruptResult blockTip(SynchronizationState, CBlockIndex&, double) override
77+
kernel::InterruptResult blockTip(SynchronizationState, const CBlockIndex&, double) override
7878
{
7979
std::cout << "Block tip changed" << std::endl;
8080
return {};

src/kernel/notifications_interface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Notifications
3737
public:
3838
virtual ~Notifications() = default;
3939

40-
[[nodiscard]] virtual InterruptResult blockTip(SynchronizationState state, CBlockIndex& index, double verification_progress) { return {}; }
40+
[[nodiscard]] virtual InterruptResult blockTip(SynchronizationState state, const CBlockIndex& index, double verification_progress) { return {}; }
4141
virtual void headerTip(SynchronizationState state, int64_t height, int64_t timestamp, bool presync) {}
4242
virtual void progress(const bilingual_str& title, int progress_percent, bool resume_possible) {}
4343
virtual void warningSet(Warning id, const bilingual_str& message) {}

src/node/kernel_notifications.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static void AlertNotify(const std::string& strMessage)
4848

4949
namespace node {
5050

51-
kernel::InterruptResult KernelNotifications::blockTip(SynchronizationState state, CBlockIndex& index, double verification_progress)
51+
kernel::InterruptResult KernelNotifications::blockTip(SynchronizationState state, const CBlockIndex& index, double verification_progress)
5252
{
5353
{
5454
LOCK(m_tip_block_mutex);

src/node/kernel_notifications.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class KernelNotifications : public kernel::Notifications
3535
KernelNotifications(const std::function<bool()>& shutdown_request, std::atomic<int>& exit_status, node::Warnings& warnings)
3636
: m_shutdown_request(shutdown_request), m_exit_status{exit_status}, m_warnings{warnings} {}
3737

38-
[[nodiscard]] kernel::InterruptResult blockTip(SynchronizationState state, CBlockIndex& index, double verification_progress) override EXCLUSIVE_LOCKS_REQUIRED(!m_tip_block_mutex);
38+
[[nodiscard]] kernel::InterruptResult blockTip(SynchronizationState state, const CBlockIndex& index, double verification_progress) override EXCLUSIVE_LOCKS_REQUIRED(!m_tip_block_mutex);
3939

4040
void headerTip(SynchronizationState state, int64_t height, int64_t timestamp, bool presync) override;
4141

0 commit comments

Comments
 (0)