From b6f0d76af4b87857ef76e0387c3b8eec81c29eb3 Mon Sep 17 00:00:00 2001 From: Fernando Pelliccioni Date: Wed, 10 Mar 2021 13:52:58 -0300 Subject: [PATCH] add start module parameter to node launch --- package-lock.json | 2 +- package.json | 2 +- src/node.cpp | 11 ++++++++--- tests/test_native.js | 3 ++- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8234bac..8ffc5b0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "kth-bch-native", - "version": "0.20.0", + "version": "0.21.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 7fe61f3..e8a3f01 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "kth-bch-native", - "version": "0.20.0", + "version": "0.21.0", "description": "Bitcoin Cash development platform for Javascript applications", "repository": { "type": "git", diff --git a/src/node.cpp b/src/node.cpp index 846a3d0..5194dcc 100644 --- a/src/node.cpp +++ b/src/node.cpp @@ -129,7 +129,7 @@ void node_init_run_and_wait_for_signal_handler(uv_async_t* handle) { void node_init_run_and_wait_for_signal(FunctionCallbackInfo const& args) { auto* isolate = args.GetIsolate(); - if (args.Length() != 2) { + if (args.Length() != 3) { throw_exception(isolate, "Wrong number of arguments"); return; } @@ -139,11 +139,16 @@ void node_init_run_and_wait_for_signal(FunctionCallbackInfo const& args) return; } - if ( ! args[1]->IsFunction()) { + if ( ! args[1]->IsNumber()) { throw_exception(isolate, "Wrong arguments, 1"); return; } + if ( ! args[2]->IsFunction()) { + throw_exception(isolate, "Wrong arguments, 2"); + return; + } + // std::cout << std::this_thread::get_id() << '\n'; void* vptr = v8::External::Cast(*args[0])->Value(); kth_node_t node = (kth_node_t)vptr; @@ -155,8 +160,8 @@ void node_init_run_and_wait_for_signal(FunctionCallbackInfo const& args) context->async = &node_init_run_and_wait_for_signal_ah_; context->callback = callback; + kth_start_modules_t mods = start_modules_to_cpp(isolate, args[1]); - kth_start_modules_t mods = kth_start_modules_all; //TODO(fernando): this is another parameter. std::thread t([node, context, mods]() { kth_node_init_run_and_wait_for_signal(node, context, mods, [](kth_node_t node, void* ctx, kth_error_code_t err) { auto* context = static_cast(ctx); diff --git a/tests/test_native.js b/tests/test_native.js index f051ab4..6de4687 100644 --- a/tests/test_native.js +++ b/tests/test_native.js @@ -161,7 +161,8 @@ async function main() { // kth.node_initchain(node) // kth.node_run_wait(node) - kth.node_init_run_and_wait_for_signal(node, function (err) { + let justChain = 1; + kth.node_init_run_and_wait_for_signal(node, justChain, function (err) { console.log(err); });