Skip to content

Commit c157a50

Browse files
committed
Merge #19840: Avoid callback when -blocknotify is empty
413e0d1 Avoid callback when -blocknotify is empty (João Barbosa) Pull request description: ACKs for top commit: MarcoFalke: ACK 413e0d1 practicalswift: ACK 413e0d1 -- patch looks correct laanwj: Code review ACK 413e0d1 Tree-SHA512: 915e796666b4e74dbb029ba5436e5573a4b881aad9e118f737bcff4024528b7ff3b00dd035138f63d30963cfd66195f6e53a2dbe429ee28cb6f0b9cc47218ecf
2 parents 8845b38 + 413e0d1 commit c157a50

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

src/init.cpp

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1833,20 +1833,15 @@ bool AppInitMain(const util::Ref& context, NodeContext& node, interfaces::BlockA
18331833
}
18341834

18351835
#if HAVE_SYSTEM
1836-
if (args.IsArgSet("-blocknotify")) {
1837-
const std::string block_notify = args.GetArg("-blocknotify", "");
1838-
const auto BlockNotifyCallback = [block_notify](SynchronizationState sync_state, const CBlockIndex* pBlockIndex) {
1839-
if (sync_state != SynchronizationState::POST_INIT || !pBlockIndex)
1840-
return;
1841-
1842-
std::string strCmd = block_notify;
1843-
if (!strCmd.empty()) {
1844-
boost::replace_all(strCmd, "%s", pBlockIndex->GetBlockHash().GetHex());
1845-
std::thread t(runCommand, strCmd);
1846-
t.detach(); // thread runs free
1847-
}
1848-
};
1849-
uiInterface.NotifyBlockTip_connect(BlockNotifyCallback);
1836+
const std::string block_notify = args.GetArg("-blocknotify", "");
1837+
if (!block_notify.empty()) {
1838+
uiInterface.NotifyBlockTip_connect([block_notify](SynchronizationState sync_state, const CBlockIndex* pBlockIndex) {
1839+
if (sync_state != SynchronizationState::POST_INIT || !pBlockIndex) return;
1840+
std::string command = block_notify;
1841+
boost::replace_all(command, "%s", pBlockIndex->GetBlockHash().GetHex());
1842+
std::thread t(runCommand, command);
1843+
t.detach(); // thread runs free
1844+
});
18501845
}
18511846
#endif
18521847

0 commit comments

Comments
 (0)