From a68e51ffc48bd6e61fdcb88344406e09dbafc716 Mon Sep 17 00:00:00 2001 From: Chris Kleeschulte Date: Tue, 18 Aug 2015 17:56:35 -0400 Subject: [PATCH 1/3] Regtest and wallet ready event - Added a check for the wallet availability during onBlocksReady - Fixed a problem with spaces being added at the end of the file by git diff --- bin/build | 5 +++-- src/libbitcoind.cc | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/bin/build b/bin/build index bb3f8b8a..189c743f 100755 --- a/bin/build +++ b/bin/build @@ -36,8 +36,9 @@ compare_patch () { cd "${btc_dir}" get_patch_file echo "running the diff command from HEAD to ${tag}" - git diff ${tag}..HEAD > /tmp/tmp.patch - matching_patch=`diff -w /tmp/tmp.patch "${root_dir}/etc/bitcoin.patch"` + diff=$(git diff ${tag}..HEAD) + stripped_diff=$( echo -n "${diff}" | head -n $( expr `echo -n "${diff}" | wc -l` - 1 ) ) + matching_patch=`echo -n "${stripped_diff}" | diff -w "${root_dir}/etc/bitcoin.patch" -` } cache_files () { diff --git a/src/libbitcoind.cc b/src/libbitcoind.cc index 5753eaa8..a0f8058a 100644 --- a/src/libbitcoind.cc +++ b/src/libbitcoind.cc @@ -471,6 +471,13 @@ async_blocks_ready(uv_work_t *req) { usleep(1E6); } + //If the wallet is enabled, then we should make sure we can load it +#if ENABLE_WALLET + while(pwalletMain->LoadWallet(fFirstRun) != DB_LOAD_OK) { + usleep(1E6); + } +#endif + // Wait until we can get a lock on cs_main // And therefore ready to be able to quickly // query for transactions from the mempool. From 862d36191b880b9eb21dd137ffc289ee8ab45d81 Mon Sep 17 00:00:00 2001 From: Chris Kleeschulte Date: Wed, 19 Aug 2015 11:01:48 -0400 Subject: [PATCH 2/3] Corrected the preprocessor directive. --- src/libbitcoind.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libbitcoind.cc b/src/libbitcoind.cc index a0f8058a..f1c16697 100644 --- a/src/libbitcoind.cc +++ b/src/libbitcoind.cc @@ -472,7 +472,7 @@ async_blocks_ready(uv_work_t *req) { } //If the wallet is enabled, then we should make sure we can load it -#if ENABLE_WALLET +#ifdef ENABLE_WALLET while(pwalletMain->LoadWallet(fFirstRun) != DB_LOAD_OK) { usleep(1E6); } From c4ee586bd7c4abf5748d89bd7f70e0e5d3a5c5c9 Mon Sep 17 00:00:00 2001 From: Chris Kleeschulte Date: Wed, 19 Aug 2015 16:33:01 -0400 Subject: [PATCH 3/3] Added CFLAGS for the bindings so that they know that the wallet is compiled in. --- bin/variables.sh | 6 ++++++ binding.gyp | 9 ++++++++- src/libbitcoind.cc | 2 +- src/libbitcoind.h | 3 +++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/bin/variables.sh b/bin/variables.sh index 77202be2..b59a1476 100755 --- a/bin/variables.sh +++ b/bin/variables.sh @@ -110,6 +110,12 @@ if test -z "$1" -o x"$1" = x'mac_dependencies'; then echo -n "${mac_response}" fi +if test -z "$1" -o x"$1" = x'wallet_enabled'; then + if [ "${BITCORENODE_ENV}" == "test" ]; then + echo -n "-DENABLE_WALLET" + fi +fi + if test -z "$1" -o x"$1" = x'bitcoind'; then echo -n "${cache_dir}"/src/.libs/libbitcoind.a fi diff --git a/binding.gyp b/binding.gyp index c4f034e3..e7a8ebb5 100644 --- a/binding.gyp +++ b/binding.gyp @@ -18,7 +18,13 @@ "xcode_settings": { "GCC_ENABLE_CPP_EXCEPTIONS": "YES", "GCC_ENABLE_CPP_RTTI": "YES", - "MACOSX_DEPLOYMENT_TARGET": "10.9" + "MACOSX_DEPLOYMENT_TARGET": "10.9", + 'OTHER_CFLAGS': [ + "-fexceptions", + "-frtti", + "-fpermissive", + "LoadWallet(fFirstRun) != DB_LOAD_OK) { + while(pwalletMain == NULL || RPCIsInWarmup(NULL)) { usleep(1E6); } #endif diff --git a/src/libbitcoind.h b/src/libbitcoind.h index b810f66a..9744f828 100644 --- a/src/libbitcoind.h +++ b/src/libbitcoind.h @@ -13,6 +13,9 @@ #include "core_io.h" #include "script/bitcoinconsensus.h" #include "consensus/validation.h" +#ifdef ENABLE_WALLET +#include "wallet/wallet.h" +#endif NAN_METHOD(StartBitcoind); NAN_METHOD(OnBlocksReady);