Skip to content

Commit feb787f

Browse files
committed
cpp: Introduce Rewind Progress handler and nofifier
This introduces a Rewind Progress notification so that it is available when generating an AssumeUTXO snapshot through the UI.
1 parent 3e5fb5b commit feb787f

8 files changed

+30
-1
lines changed

Diff for: src/interfaces/node.h

+4
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,10 @@ class Node
251251
using SnapshotLoadProgressFn = std::function<void(double progress)>;
252252
virtual std::unique_ptr<Handler> handleSnapshotLoadProgress(SnapshotLoadProgressFn fn) = 0;
253253

254+
//! Register handler for rewind progress messages.
255+
using RewindProgressFn = std::function<void(double progress)>;
256+
virtual std::unique_ptr<Handler> handleRewindProgress(RewindProgressFn fn) = 0;
257+
254258
//! Register handler for wallet loader constructed messages.
255259
using InitWalletFn = std::function<void()>;
256260
virtual std::unique_ptr<Handler> handleInitWallet(InitWalletFn fn) = 0;

Diff for: src/kernel/notifications_interface.h

+2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@ class Notifications
3939

4040
[[nodiscard]] virtual InterruptResult blockTip(SynchronizationState state, CBlockIndex& index) { return {}; }
4141
virtual void headerTip(SynchronizationState state, int64_t height, int64_t timestamp, bool presync) {}
42+
virtual void blockTipDisconnected(SynchronizationState state, CBlockIndex& index) {}
4243
virtual void progress(const bilingual_str& title, int progress_percent, bool resume_possible) {}
4344
virtual void snapshotLoadProgress(double progress) {}
45+
virtual void rewindProgress(double progress) {}
4446
virtual void warning(const bilingual_str& warning) {}
4547

4648
//! The flush error notification is sent to notify the user that an error

Diff for: src/node/interface_ui.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ struct UISignals {
2222
boost::signals2::signal<CClientUIInterface::NotifyAlertChangedSig> NotifyAlertChanged;
2323
boost::signals2::signal<CClientUIInterface::ShowProgressSig> ShowProgress;
2424
boost::signals2::signal<CClientUIInterface::SnapshotLoadProgressSig> SnapshotLoadProgress;
25+
boost::signals2::signal<CClientUIInterface::RewindProgressSig> RewindProgress;
2526
boost::signals2::signal<CClientUIInterface::NotifyBlockTipSig> NotifyBlockTip;
2627
boost::signals2::signal<CClientUIInterface::NotifyHeaderTipSig> NotifyHeaderTip;
28+
boost::signals2::signal<CClientUIInterface::NotifyBlockDisconnectedSig> NotifyBlockDisconnected;
2729
boost::signals2::signal<CClientUIInterface::BannedListChangedSig> BannedListChanged;
2830
};
2931
static UISignals g_ui_signals;
@@ -44,9 +46,10 @@ ADD_SIGNALS_IMPL_WRAPPER(NotifyAlertChanged);
4446
ADD_SIGNALS_IMPL_WRAPPER(ShowProgress);
4547
ADD_SIGNALS_IMPL_WRAPPER(NotifyBlockTip);
4648
ADD_SIGNALS_IMPL_WRAPPER(NotifyHeaderTip);
49+
ADD_SIGNALS_IMPL_WRAPPER(NotifyBlockDisconnected);
4750
ADD_SIGNALS_IMPL_WRAPPER(BannedListChanged);
4851
ADD_SIGNALS_IMPL_WRAPPER(SnapshotLoadProgress);
49-
52+
ADD_SIGNALS_IMPL_WRAPPER(RewindProgress);
5053
bool CClientUIInterface::ThreadSafeMessageBox(const bilingual_str& message, const std::string& caption, unsigned int style) { return g_ui_signals.ThreadSafeMessageBox(message, caption, style).value_or(false);}
5154
bool CClientUIInterface::ThreadSafeQuestion(const bilingual_str& message, const std::string& non_interactive_message, const std::string& caption, unsigned int style) { return g_ui_signals.ThreadSafeQuestion(message, non_interactive_message, caption, style).value_or(false);}
5255
void CClientUIInterface::InitMessage(const std::string& message) { return g_ui_signals.InitMessage(message); }
@@ -56,8 +59,10 @@ void CClientUIInterface::NotifyNetworkActiveChanged(bool networkActive) { return
5659
void CClientUIInterface::NotifyAlertChanged() { return g_ui_signals.NotifyAlertChanged(); }
5760
void CClientUIInterface::ShowProgress(const std::string& title, int nProgress, bool resume_possible) { return g_ui_signals.ShowProgress(title, nProgress, resume_possible); }
5861
void CClientUIInterface::SnapshotLoadProgress(double progress) { return g_ui_signals.SnapshotLoadProgress(progress); }
62+
void CClientUIInterface::RewindProgress(double progress) { return g_ui_signals.RewindProgress(progress); }
5963
void CClientUIInterface::NotifyBlockTip(SynchronizationState s, const CBlockIndex* i) { return g_ui_signals.NotifyBlockTip(s, i); }
6064
void CClientUIInterface::NotifyHeaderTip(SynchronizationState s, int64_t height, int64_t timestamp, bool presync) { return g_ui_signals.NotifyHeaderTip(s, height, timestamp, presync); }
65+
void CClientUIInterface::NotifyBlockDisconnected(SynchronizationState s, const CBlockIndex* i) { return g_ui_signals.NotifyBlockDisconnected(s, i); }
6166
void CClientUIInterface::BannedListChanged() { return g_ui_signals.BannedListChanged(); }
6267

6368
bool InitError(const bilingual_str& str)

Diff for: src/node/interface_ui.h

+6
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,18 @@ class CClientUIInterface
112112
/** Snapshot load progress. */
113113
ADD_SIGNALS_DECL_WRAPPER(SnapshotLoadProgress, void, double progress);
114114

115+
/** Rewind progress. */
116+
ADD_SIGNALS_DECL_WRAPPER(RewindProgress, void, double progress);
117+
115118
/** New block has been accepted */
116119
ADD_SIGNALS_DECL_WRAPPER(NotifyBlockTip, void, SynchronizationState, const CBlockIndex*);
117120

118121
/** Best header has changed */
119122
ADD_SIGNALS_DECL_WRAPPER(NotifyHeaderTip, void, SynchronizationState, int64_t height, int64_t timestamp, bool presync);
120123

124+
/** Block disconnected */
125+
ADD_SIGNALS_DECL_WRAPPER(NotifyBlockDisconnected, void, SynchronizationState, const CBlockIndex*);
126+
121127
/** Banlist did change. */
122128
ADD_SIGNALS_DECL_WRAPPER(BannedListChanged, void, void);
123129
};

Diff for: src/node/interfaces.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,10 @@ class NodeImpl : public Node
383383
{
384384
return MakeSignalHandler(::uiInterface.SnapshotLoadProgress_connect(fn));
385385
}
386+
std::unique_ptr<Handler> handleRewindProgress(RewindProgressFn fn) override
387+
{
388+
return MakeSignalHandler(::uiInterface.RewindProgress_connect(fn));
389+
}
386390
std::unique_ptr<Handler> handleInitWallet(InitWalletFn fn) override
387391
{
388392
return MakeSignalHandler(::uiInterface.InitWallet_connect(fn));

Diff for: src/node/kernel_notifications.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ void KernelNotifications::snapshotLoadProgress(double progress)
8383
uiInterface.SnapshotLoadProgress(progress);
8484
}
8585

86+
void KernelNotifications::rewindProgress(double progress)
87+
{
88+
uiInterface.RewindProgress(progress);
89+
}
90+
8691
void KernelNotifications::warning(const bilingual_str& warning)
8792
{
8893
DoWarning(warning);

Diff for: src/node/kernel_notifications.h

+2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ class KernelNotifications : public kernel::Notifications
3333

3434
void snapshotLoadProgress(double progress) override;
3535

36+
void rewindProgress(double progress) override;
37+
3638
void warning(const bilingual_str& warning) override;
3739

3840
void flushError(const std::string& debug_message) override;

Diff for: src/validation.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -2661,6 +2661,7 @@ void Chainstate::UpdateTip(const CBlockIndex* pindexNew)
26612661
}
26622662
}
26632663
}
2664+
m_chainman.GetNotifications().rewindProgress(GuessVerificationProgress(params.TxData(), pindexNew));
26642665
UpdateTipLog(coins_tip, pindexNew, params, __func__, "", warning_messages.original);
26652666
}
26662667

0 commit comments

Comments
 (0)