mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-06 05:37:50 +02:00
refactor: Pass verification_progress into block tip notifications
It is cheap to calculate and the caller does not have to take a lock to calculate it. Also turn pointers that can never be null into references.
This commit is contained in:
@@ -1787,10 +1787,10 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
||||
#if HAVE_SYSTEM
|
||||
const std::string block_notify = args.GetArg("-blocknotify", "");
|
||||
if (!block_notify.empty()) {
|
||||
uiInterface.NotifyBlockTip_connect([block_notify](SynchronizationState sync_state, const CBlockIndex* pBlockIndex) {
|
||||
if (sync_state != SynchronizationState::POST_INIT || !pBlockIndex) return;
|
||||
uiInterface.NotifyBlockTip_connect([block_notify](SynchronizationState sync_state, const CBlockIndex& block, double /* verification_progress */) {
|
||||
if (sync_state != SynchronizationState::POST_INIT) return;
|
||||
std::string command = block_notify;
|
||||
ReplaceAll(command, "%s", pBlockIndex->GetBlockHash().GetHex());
|
||||
ReplaceAll(command, "%s", block.GetBlockHash().GetHex());
|
||||
std::thread t(runCommand, command);
|
||||
t.detach(); // thread runs free
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user