aboutsummaryrefslogtreecommitdiff
path: root/src/init.cpp
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2020-08-22 09:44:49 +0200
committerMarcoFalke <falke.marco@gmail.com>2020-08-24 07:51:48 +0200
commitfa33bc2dabbbd2d73961f9b0ce51420a3b6e4ad5 (patch)
tree1708499fbe1d0a71877437e27da176bc8cb9df7a /src/init.cpp
parentfa40017706e08b4de111e8e57aabeced60881a57 (diff)
downloadbitcoin-fa33bc2dabbbd2d73961f9b0ce51420a3b6e4ad5.tar.xz
init: Capture copy of blocknotify setting for BlockNotifyCallback
Can be reviewed with --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space
Diffstat (limited to 'src/init.cpp')
-rw-r--r--src/init.cpp30
1 files changed, 14 insertions, 16 deletions
diff --git a/src/init.cpp b/src/init.cpp
index ac18a266b9..d01a98fc56 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -600,21 +600,6 @@ std::string LicenseInfo()
"\n";
}
-#if HAVE_SYSTEM
-static void BlockNotifyCallback(SynchronizationState sync_state, const CBlockIndex* pBlockIndex)
-{
- if (sync_state != SynchronizationState::POST_INIT || !pBlockIndex)
- return;
-
- std::string strCmd = gArgs.GetArg("-blocknotify", "");
- if (!strCmd.empty()) {
- boost::replace_all(strCmd, "%s", pBlockIndex->GetBlockHash().GetHex());
- std::thread t(runCommand, strCmd);
- t.detach(); // thread runs free
- }
-}
-#endif
-
static bool fHaveGenesis = false;
static Mutex g_genesis_wait_mutex;
static std::condition_variable g_genesis_wait_cv;
@@ -1847,8 +1832,21 @@ bool AppInitMain(const util::Ref& context, NodeContext& node, interfaces::BlockA
}
#if HAVE_SYSTEM
- if (gArgs.IsArgSet("-blocknotify"))
+ 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);
+ }
#endif
std::vector<fs::path> vImportFiles;