Make validation interface capable of signalling header presync
This makes a number of changes: - Get rid of the verification_progress argument in the node interface NotifyHeaderTip (it was always 0.0). - Instead of passing a CBlockIndex* in the UI interface's NotifyHeaderTip, send separate height, timestamp fields. This is becuase in headers presync, no actual CBlockIndex object is available. - Add a bool presync argument to both of the above, to identify signals pertaining to the first headers sync phase.
This commit is contained in:
1 parent
93eae27031
commit
376086fc5a
6 files changed
+8
-9
No files matched your search
@@ -260,7 +260,7 @@ public:
|
|||||||
|
|
||||||
//! Register handler for header tip messages.
|
//! Register handler for header tip messages.
|
||||||
using NotifyHeaderTipFn =
|
using NotifyHeaderTipFn =
|
||||||
std::function<void(SynchronizationState, interfaces::BlockTip tip, double verification_progress)>;
|
std::function<void(SynchronizationState, interfaces::BlockTip tip, bool presync)>;
|
||||||
virtual std::unique_ptr<Handler> handleNotifyHeaderTip(NotifyHeaderTipFn fn) = 0;
|
virtual std::unique_ptr<Handler> handleNotifyHeaderTip(NotifyHeaderTipFn fn) = 0;
|
||||||
|
|
||||||
//! Get and set internal node context. Useful for testing, but not
|
//! Get and set internal node context. Useful for testing, but not
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ void CClientUIInterface::NotifyNetworkActiveChanged(bool networkActive) { return
|
|||||||
void CClientUIInterface::NotifyAlertChanged() { return g_ui_signals.NotifyAlertChanged(); }
|
void CClientUIInterface::NotifyAlertChanged() { return g_ui_signals.NotifyAlertChanged(); }
|
||||||
void CClientUIInterface::ShowProgress(const std::string& title, int nProgress, bool resume_possible) { return g_ui_signals.ShowProgress(title, nProgress, resume_possible); }
|
void CClientUIInterface::ShowProgress(const std::string& title, int nProgress, bool resume_possible) { return g_ui_signals.ShowProgress(title, nProgress, resume_possible); }
|
||||||
void CClientUIInterface::NotifyBlockTip(SynchronizationState s, const CBlockIndex* i) { return g_ui_signals.NotifyBlockTip(s, i); }
|
void CClientUIInterface::NotifyBlockTip(SynchronizationState s, const CBlockIndex* i) { return g_ui_signals.NotifyBlockTip(s, i); }
|
||||||
void CClientUIInterface::NotifyHeaderTip(SynchronizationState s, const CBlockIndex* i) { return g_ui_signals.NotifyHeaderTip(s, i); }
|
void CClientUIInterface::NotifyHeaderTip(SynchronizationState s, int64_t height, int64_t timestamp, bool presync) { return g_ui_signals.NotifyHeaderTip(s, height, timestamp, presync); }
|
||||||
void CClientUIInterface::BannedListChanged() { return g_ui_signals.BannedListChanged(); }
|
void CClientUIInterface::BannedListChanged() { return g_ui_signals.BannedListChanged(); }
|
||||||
|
|
||||||
bool InitError(const bilingual_str& str)
|
bool InitError(const bilingual_str& str)
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ public:
|
|||||||
ADD_SIGNALS_DECL_WRAPPER(NotifyBlockTip, void, SynchronizationState, const CBlockIndex*);
|
ADD_SIGNALS_DECL_WRAPPER(NotifyBlockTip, void, SynchronizationState, const CBlockIndex*);
|
||||||
|
|
||||||
/** Best header has changed */
|
/** Best header has changed */
|
||||||
ADD_SIGNALS_DECL_WRAPPER(NotifyHeaderTip, void, SynchronizationState, const CBlockIndex*);
|
ADD_SIGNALS_DECL_WRAPPER(NotifyHeaderTip, void, SynchronizationState, int64_t height, int64_t timestamp, bool presync);
|
||||||
|
|
||||||
/** Banlist did change. */
|
/** Banlist did change. */
|
||||||
ADD_SIGNALS_DECL_WRAPPER(BannedListChanged, void, void);
|
ADD_SIGNALS_DECL_WRAPPER(BannedListChanged, void, void);
|
||||||
|
|||||||
@@ -377,9 +377,8 @@ public:
|
|||||||
std::unique_ptr<Handler> handleNotifyHeaderTip(NotifyHeaderTipFn fn) override
|
std::unique_ptr<Handler> handleNotifyHeaderTip(NotifyHeaderTipFn fn) override
|
||||||
{
|
{
|
||||||
return MakeHandler(
|
return MakeHandler(
|
||||||
::uiInterface.NotifyHeaderTip_connect([fn](SynchronizationState sync_state, const CBlockIndex* block) {
|
::uiInterface.NotifyHeaderTip_connect([fn](SynchronizationState sync_state, int64_t height, int64_t timestamp, bool presync) {
|
||||||
fn(sync_state, BlockTip{block->nHeight, block->GetBlockTime(), block->GetBlockHash()},
|
fn(sync_state, BlockTip{(int)height, timestamp, uint256{}}, presync);
|
||||||
/* verification progress is unused when a header was received */ 0);
|
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
NodeContext* context() override { return m_context; }
|
NodeContext* context() override { return m_context; }
|
||||||
|
|||||||
@@ -267,8 +267,8 @@ void ClientModel::subscribeToCoreSignals()
|
|||||||
TipChanged(sync_state, tip, verification_progress, /*header=*/false);
|
TipChanged(sync_state, tip, verification_progress, /*header=*/false);
|
||||||
});
|
});
|
||||||
m_handler_notify_header_tip = m_node.handleNotifyHeaderTip(
|
m_handler_notify_header_tip = m_node.handleNotifyHeaderTip(
|
||||||
[this](SynchronizationState sync_state, interfaces::BlockTip tip, double verification_progress) {
|
[this](SynchronizationState sync_state, interfaces::BlockTip tip, bool presync) {
|
||||||
TipChanged(sync_state, tip, verification_progress, /*header=*/true);
|
if (!presync) TipChanged(sync_state, tip, /*verification_progress=*/0.0, /*header=*/true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -2944,7 +2944,7 @@ static bool NotifyHeaderTip(CChainState& chainstate) LOCKS_EXCLUDED(cs_main) {
|
|||||||
}
|
}
|
||||||
// Send block tip changed notifications without cs_main
|
// Send block tip changed notifications without cs_main
|
||||||
if (fNotify) {
|
if (fNotify) {
|
||||||
uiInterface.NotifyHeaderTip(GetSynchronizationState(fInitialBlockDownload), pindexHeader);
|
uiInterface.NotifyHeaderTip(GetSynchronizationState(fInitialBlockDownload), pindexHeader->nHeight, pindexHeader->nTime, false);
|
||||||
}
|
}
|
||||||
return fNotify;
|
return fNotify;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user