Added some fixes for the bindings.gyp file.

This commit is contained in:
Chris Kleeschulte 2015-06-26 16:03:43 -04:00
parent ab598e3523
commit 2039e4c6dc
8 changed files with 115 additions and 28 deletions

View File

@ -1,10 +1,93 @@
'use strict' 'use strict'
var assert = require('assert');
var benchmark = require('benchmark');
var bitcoinconsensus = require('../');
var bitcoin = require('bitcoin');
var async = require('async');
var maxTime = 10;
console.log('Benchmarking Bitcoind.js native interface versus Bitcoind JSON RPC interface');
console.log('----------------------------------------------------------------------');
// The primary methods needed are: // The primary methods needed are:
// getInfo // getInfo === works
// getRawTransaction // getRawTransactioni === getrawtransaction "txid" ( verbose )
// sendRawTransaction // sendRawTransaction === sendrawtransaction "hexstring" ( allowhighfees )
// getTransaction // getTransaction === either I need txindex turned on -or- the wallet turned on
// Wallet functionality isn't needed, and libbitcoind.so could be compiled with the --disable-wallet flag. // Wallet functionality isn't needed, and libbitcoind.so could be compiled with the --disable-wallet flag.
var fixtureData = {
transactions: [
'5523b432c1bd6c101bee704ad6c560fd09aefc483f8a4998df6741feaa74e6eb',
'ff48393e7731507c789cfa9cbfae045b10e023ce34ace699a63cdad88c8b43f8',
'5d35c5eebf704877badd0a131b0a86588041997d40dbee8ccff21ca5b7e5e333',
'88842f2cf9d8659c3434f6bc0c515e22d87f33e864e504d2d7117163a572a3aa',
]
}
var bitcoind = require('../')({
directory: '~/.libbitcoind-example'
});
bitcoind.on('error', function(err) {
bitcoind.log('error="%s"', err.message);
});
bitcoind.on('open', function(status) {
bitcoind.log('status="%s"', status);
var client = new bitcoin.Client({
host: 'localhost',
port: 18332,
user: 'bitpaytest',
pass: 'local321'
});
async.series([
function(next) {
function bitcoindJsonRpc() {
client.getInfo();
// var item = Math.floor((Math.random() * fixtures.length));
// var data = fixtureData.transactions[item];
//
// client.getTransaction(data, function(err, tx) {
// assert.equal(err, null);
// });
}
function bitcoindNative() {
bitcoind.getInfo();
// var item = Math.floor((Math.random() * fixtures.length));
// var data = fixtureData.transaction[item];
//
// bitcoind.getTransaction(data, function(err, tx) {
// assert.equal(err, null);
// });
}
var suite = new benchmark.Suite();
suite.add('bitcoind json rpc', bitcoindJsonRpc, { maxTime: maxTime });
suite.add('bitcoind native', bitcoindNative, { maxTime: maxTime });
suite
.on('cycle', function(event) {
console.log(String(event.target));
})
.on('complete', function() {
console.log('Fastest is ' + this.filter('fastest').pluck('name'));
console.log('----------------------------------------------------------------------');
next();
})
.run();
}
], function(err) {
console.log('Finished');
bitcoind.stop();
process.exit();
});
});

View File

@ -20,7 +20,6 @@
'<(BOOST_INCLUDE)', '<(BOOST_INCLUDE)',
'<(LEVELDB_INCLUDE)', '<(LEVELDB_INCLUDE)',
'<(BITCOIN_DIR)/src', '<(BITCOIN_DIR)/src',
'/usr/local/Cellar/openssl/1.0.2a-1/include',
'./libbitcoind/src/secp256k1/include', './libbitcoind/src/secp256k1/include',
'./libbitcoind/src/leveldb/helpers/memenv', './libbitcoind/src/leveldb/helpers/memenv',
'<!(node -e "require(\'nan\')")', '<!(node -e "require(\'nan\')")',
@ -34,8 +33,15 @@
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES', 'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
'GCC_ENABLE_CPP_RTTI': 'YES', 'GCC_ENABLE_CPP_RTTI': 'YES',
'MACOSX_DEPLOYMENT_TARGET': '10.9' 'MACOSX_DEPLOYMENT_TARGET': '10.9'
},
'libraries': {
'-lboost_thread-mt'
} }
}] },
'OS=="linux"', {
'-lboost_thread'
}
]
], ],
'cflags_cc': [ 'cflags_cc': [
'-fexceptions', '-fexceptions',
@ -49,7 +55,6 @@
'-lboost_system', '-lboost_system',
'-lboost_filesystem', '-lboost_filesystem',
'-lboost_program_options', '-lboost_program_options',
'-lboost_thread-mt',
'-lboost_chrono', '-lboost_chrono',
'<(LIBBITCOIND)', '<(LIBBITCOIND)',
] ]

View File

@ -135,12 +135,10 @@ bitcoind.on('open', function(status) {
bitcoind.log('status="%s"', status); bitcoind.log('status="%s"', status);
if (argv.list) { if (argv.list) {
bitcoind.log('args list true'); return;
return bitcoind.log(bitcoind.wallet.listAccounts());
} }
if (argv.blocks) { if (argv.blocks) {
bitcoind.log('args block true');
return getBlocks(bitcoind); return getBlocks(bitcoind);
} }

View File

@ -193,11 +193,6 @@ Bitcoin.prototype.start = function(options, callback) {
} }
}); });
// XXX -txindex currently causes a segfault during blockchain download
// if (options.txindex !== false) {
// options.txindex = true;
// }
bitcoindjs.start(options, function(err, status) { bitcoindjs.start(options, function(err, status) {
self._started = true; self._started = true;

View File

@ -25,6 +25,8 @@
"devDependencies": { "devDependencies": {
"mocha": "~1.16.2", "mocha": "~1.16.2",
"optimist": "0.6.0", "optimist": "0.6.0",
"rimraf": "2.2.8" "rimraf": "2.2.8",
"async": "1.2.1",
"benchmark": "1.0.0"
} }
} }

View File

@ -2,14 +2,17 @@
exec 2> /dev/null exec 2> /dev/null
if test x"$1" = x'btcdir'; then btcdir() {
if test -n "$BITCOIN_DIR"; then if test -d "$(pwd)/libbitcoind"; then
echo "$BITCOIND_DIR" BITCOIN_DIR="$(pwd)/libbitcoind"
elif test -d "$(pwd)/libbitcoind"; then
echo "$(pwd)/libbitcoind"
elif test -d "${HOME}/bitcoin"; then elif test -d "${HOME}/bitcoin"; then
echo "${HOME}/bitcoin" BITCOIN_DIR="${HOME}/bitcoin"
fi fi
}
if test x"$1" = x'btcdir'; then
btcdir
echo $BITCOIN_DIR
exit 0 exit 0
fi fi
@ -66,10 +69,10 @@ if test x"$1" = x'osdir'; then
echo -n "$(pwd)/platform/${os}" echo -n "$(pwd)/platform/${os}"
exit 0 exit 0
fi fi
echo $ext
if test -z "$1" -o x"$1" = x'lib'; then if test -z "$1" -o x"$1" = x'lib'; then
if test -n "$BITCOIN_DIR" -a -e "${BITCOIN_DIR}/src/.libs/libbitcoind.${ext}"; then btcdir
echo -n "$(pwd)/libbitcoind/src/.libs/libbitcoind.${ext}" if test -n "${BITCOIN_DIR}" -a -e "${BITCOIN_DIR}/src/.libs/libbitcoind.${ext}"; then
echo -n "${BITCOIN_DIR}/src/.libs/libbitcoind.${ext}"
else else
echo -n "$(pwd)/platform/${os}/libbitcoind.${ext}" echo -n "$(pwd)/platform/${os}/libbitcoind.${ext}"
fi fi

View File

@ -6,10 +6,8 @@
* A bitcoind node.js binding. * A bitcoind node.js binding.
*/ */
#include "bitcoindjs.h" #include "bitcoindjs.h"
using namespace std; using namespace std;
using namespace boost; using namespace boost;
using namespace node; using namespace node;
@ -536,7 +534,9 @@ start_node_thread(void) {
detectShutdownThread = new boost::thread( detectShutdownThread = new boost::thread(
boost::bind(&DetectShutdownThread, &threadGroup)); boost::bind(&DetectShutdownThread, &threadGroup));
fRet = AppInit2(threadGroup); fRet = AppInit2(threadGroup);
} catch (std::exception& e) { } catch (std::exception& e) {
if (set_cooked()) { if (set_cooked()) {
fprintf(stderr, "bitcoind.js: AppInit(): std::exception\n"); fprintf(stderr, "bitcoind.js: AppInit(): std::exception\n");
@ -572,6 +572,7 @@ start_node_thread(void) {
*/ */
NAN_METHOD(StopBitcoind) { NAN_METHOD(StopBitcoind) {
fprintf(stderr, "Stopping Bitcoind please wait!");
Isolate* isolate = Isolate::GetCurrent(); Isolate* isolate = Isolate::GetCurrent();
HandleScope scope(isolate); HandleScope scope(isolate);
@ -746,6 +747,7 @@ async_get_block(uv_work_t *req) {
std::string strHash = data->hash; std::string strHash = data->hash;
uint256 hash(strHash); uint256 hash(strHash);
CBlock cblock; CBlock cblock;
CBlockIndex* pblockindex = mapBlockIndex[hash]; CBlockIndex* pblockindex = mapBlockIndex[hash];
if (ReadBlockFromDisk(cblock, pblockindex)) { if (ReadBlockFromDisk(cblock, pblockindex)) {

View File

@ -159,7 +159,6 @@
#define USE_LDB_ADDR 0 #define USE_LDB_ADDR 0
#define USE_LDB_TX 0 #define USE_LDB_TX 0
#define SHUTTING_DOWN() (ShutdownRequested() || shutdown_complete)
/** /**
* Node.js Exposed Function Templates * Node.js Exposed Function Templates