From 70edf28235f4ec2554288ed200037e98b3e60a93 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Tue, 30 Sep 2014 15:53:13 -0700 Subject: [PATCH] attempt to use function hooks. --- binding.gyp | 1 + lib/bitcoind.js | 4 ++-- src/bitcoindjs.cc | 38 +++++++++++++++++++++++++++++++++++++- 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/binding.gyp b/binding.gyp index 22b905fb..62ba66d0 100644 --- a/binding.gyp +++ b/binding.gyp @@ -41,6 +41,7 @@ 'cflags_cc': [ '-fexceptions', '-frtti', + # '-finstrument-functions', ], 'libraries': [ # standard libs: diff --git a/lib/bitcoind.js b/lib/bitcoind.js index 2b088f16..a59a4142 100644 --- a/lib/bitcoind.js +++ b/lib/bitcoind.js @@ -57,7 +57,7 @@ process.on = function(name, listener) { return; } } - return on.apply(this, arguments); + return Bitcoin._processOn.apply(this, arguments); }; Bitcoin.prototype.start = function(callback) { @@ -92,7 +92,7 @@ Bitcoin.prototype.start = function(callback) { }); // Finally set signal handlers - process.on = process.addListener = Bitcoind._processOn; + process.on = process.addListener = Bitcoin._processOn; Bitcoin._signalQueue.forEach(function(event) { process.on(event[0], event[1]); }); diff --git a/src/bitcoindjs.cc b/src/bitcoindjs.cc index 2def4cc3..9105ea60 100644 --- a/src/bitcoindjs.cc +++ b/src/bitcoindjs.cc @@ -88,6 +88,7 @@ #include #include +#include #include #include @@ -1226,7 +1227,7 @@ NAN_METHOD(FillTransaction) { } Local js_tx = Local::Cast(args[0]); - Local options = Local::Cast(args[1]); + // Local options = Local::Cast(args[1]); String::Utf8Value tx_hex_(js_tx->Get(NanNew("hex"))->ToString()); std::string tx_hex = std::string(*tx_hex_); @@ -2366,6 +2367,41 @@ jstx_to_ctx(const Local entry, CTransaction& tx, uint256 hashBlock) { } #endif +/** + * Hooks + */ + +#if 0 +static int last_height = -1; + +extern "C" void __attribute__ ((constructor)) +trace_begin(void) { + return; +} + +extern "C" void __attribute__ ((destructor)) +trace_end(void) { + return; +} + +extern "C" void +__cyg_profile_func_enter(void *func, void *caller) { + return; +} + +extern "C" void +__cyg_profile_func_exit(void *func, void *caller) { + int cur_height = chainActive.Height(); + if (cur_height != last_height) { + printf("new block\n"); + last_height = cur_height; + } + // if (func == &AcceptBlock || caller == &AcceptBlock || func == AcceptBlock || caller == AcceptBlock) { + // printf("accept block\n"); + // } +} +#endif + /** * Init */