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:
MarcoFalke
2025-05-20 10:46:59 +02:00
parent fa76b378e4
commit fab1e02086
9 changed files with 25 additions and 17 deletions

View File

@@ -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
});