diff options
author | Wladimir J. van der Laan <laanwj@protonmail.com> | 2020-09-02 15:09:06 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@protonmail.com> | 2020-09-02 15:14:34 +0200 |
commit | c157a50694545090cb1c7e69123fe4709bd5a279 (patch) | |
tree | 094aa34d7619105f3bbcfdd51e6a72b508ab4dc1 | |
parent | 8845b38b599e15eb8073b679b55eec953fe9d171 (diff) | |
parent | 413e0d1d31ede6a9b539d63ec814b6e8044e35e2 (diff) | |
download | bitcoin-c157a50694545090cb1c7e69123fe4709bd5a279.tar.xz |
Merge #19840: Avoid callback when -blocknotify is empty
413e0d1d31ede6a9b539d63ec814b6e8044e35e2 Avoid callback when -blocknotify is empty (João Barbosa)
Pull request description:
ACKs for top commit:
MarcoFalke:
ACK 413e0d1d31ede6a9b539d63ec814b6e8044e35e2
practicalswift:
ACK 413e0d1d31ede6a9b539d63ec814b6e8044e35e2 -- patch looks correct
laanwj:
Code review ACK 413e0d1d31ede6a9b539d63ec814b6e8044e35e2
Tree-SHA512: 915e796666b4e74dbb029ba5436e5573a4b881aad9e118f737bcff4024528b7ff3b00dd035138f63d30963cfd66195f6e53a2dbe429ee28cb6f0b9cc47218ecf
-rw-r--r-- | src/init.cpp | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/src/init.cpp b/src/init.cpp index 4b689d6153..bb93f5c797 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1833,20 +1833,15 @@ bool AppInitMain(const util::Ref& context, NodeContext& node, interfaces::BlockA } #if HAVE_SYSTEM - if (args.IsArgSet("-blocknotify")) { - const std::string block_notify = args.GetArg("-blocknotify", ""); - const auto BlockNotifyCallback = [block_notify](SynchronizationState sync_state, const CBlockIndex* pBlockIndex) { - if (sync_state != SynchronizationState::POST_INIT || !pBlockIndex) - return; - - std::string strCmd = block_notify; - if (!strCmd.empty()) { - boost::replace_all(strCmd, "%s", pBlockIndex->GetBlockHash().GetHex()); - std::thread t(runCommand, strCmd); - t.detach(); // thread runs free - } - }; - uiInterface.NotifyBlockTip_connect(BlockNotifyCallback); + 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; + std::string command = block_notify; + boost::replace_all(command, "%s", pBlockIndex->GetBlockHash().GetHex()); + std::thread t(runCommand, command); + t.detach(); // thread runs free + }); } #endif |