Added some fixes for the bindings.gyp file.
This commit is contained in:
parent
ab598e3523
commit
2039e4c6dc
|
@ -1,10 +1,93 @@
|
|||
'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:
|
||||
|
||||
// getInfo
|
||||
// getRawTransaction
|
||||
// sendRawTransaction
|
||||
// getTransaction
|
||||
// getInfo === works
|
||||
// getRawTransactioni === getrawtransaction "txid" ( verbose )
|
||||
// sendRawTransaction === sendrawtransaction "hexstring" ( allowhighfees )
|
||||
// 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.
|
||||
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();
|
||||
});
|
||||
});
|
||||
|
|
11
binding.gyp
11
binding.gyp
|
@ -20,7 +20,6 @@
|
|||
'<(BOOST_INCLUDE)',
|
||||
'<(LEVELDB_INCLUDE)',
|
||||
'<(BITCOIN_DIR)/src',
|
||||
'/usr/local/Cellar/openssl/1.0.2a-1/include',
|
||||
'./libbitcoind/src/secp256k1/include',
|
||||
'./libbitcoind/src/leveldb/helpers/memenv',
|
||||
'<!(node -e "require(\'nan\')")',
|
||||
|
@ -34,8 +33,15 @@
|
|||
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
|
||||
'GCC_ENABLE_CPP_RTTI': 'YES',
|
||||
'MACOSX_DEPLOYMENT_TARGET': '10.9'
|
||||
},
|
||||
'libraries': {
|
||||
'-lboost_thread-mt'
|
||||
}
|
||||
}]
|
||||
},
|
||||
'OS=="linux"', {
|
||||
'-lboost_thread'
|
||||
}
|
||||
]
|
||||
],
|
||||
'cflags_cc': [
|
||||
'-fexceptions',
|
||||
|
@ -49,7 +55,6 @@
|
|||
'-lboost_system',
|
||||
'-lboost_filesystem',
|
||||
'-lboost_program_options',
|
||||
'-lboost_thread-mt',
|
||||
'-lboost_chrono',
|
||||
'<(LIBBITCOIND)',
|
||||
]
|
||||
|
|
|
@ -135,12 +135,10 @@ bitcoind.on('open', function(status) {
|
|||
bitcoind.log('status="%s"', status);
|
||||
|
||||
if (argv.list) {
|
||||
bitcoind.log('args list true');
|
||||
return bitcoind.log(bitcoind.wallet.listAccounts());
|
||||
return;
|
||||
}
|
||||
|
||||
if (argv.blocks) {
|
||||
bitcoind.log('args block true');
|
||||
return getBlocks(bitcoind);
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
||||
self._started = true;
|
||||
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
"devDependencies": {
|
||||
"mocha": "~1.16.2",
|
||||
"optimist": "0.6.0",
|
||||
"rimraf": "2.2.8"
|
||||
"rimraf": "2.2.8",
|
||||
"async": "1.2.1",
|
||||
"benchmark": "1.0.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,14 +2,17 @@
|
|||
|
||||
exec 2> /dev/null
|
||||
|
||||
if test x"$1" = x'btcdir'; then
|
||||
if test -n "$BITCOIN_DIR"; then
|
||||
echo "$BITCOIND_DIR"
|
||||
elif test -d "$(pwd)/libbitcoind"; then
|
||||
echo "$(pwd)/libbitcoind"
|
||||
btcdir() {
|
||||
if test -d "$(pwd)/libbitcoind"; then
|
||||
BITCOIN_DIR="$(pwd)/libbitcoind"
|
||||
elif test -d "${HOME}/bitcoin"; then
|
||||
echo "${HOME}/bitcoin"
|
||||
BITCOIN_DIR="${HOME}/bitcoin"
|
||||
fi
|
||||
}
|
||||
|
||||
if test x"$1" = x'btcdir'; then
|
||||
btcdir
|
||||
echo $BITCOIN_DIR
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
@ -66,10 +69,10 @@ if test x"$1" = x'osdir'; then
|
|||
echo -n "$(pwd)/platform/${os}"
|
||||
exit 0
|
||||
fi
|
||||
echo $ext
|
||||
if test -z "$1" -o x"$1" = x'lib'; then
|
||||
if test -n "$BITCOIN_DIR" -a -e "${BITCOIN_DIR}/src/.libs/libbitcoind.${ext}"; then
|
||||
echo -n "$(pwd)/libbitcoind/src/.libs/libbitcoind.${ext}"
|
||||
btcdir
|
||||
if test -n "${BITCOIN_DIR}" -a -e "${BITCOIN_DIR}/src/.libs/libbitcoind.${ext}"; then
|
||||
echo -n "${BITCOIN_DIR}/src/.libs/libbitcoind.${ext}"
|
||||
else
|
||||
echo -n "$(pwd)/platform/${os}/libbitcoind.${ext}"
|
||||
fi
|
||||
|
|
|
@ -6,10 +6,8 @@
|
|||
* A bitcoind node.js binding.
|
||||
*/
|
||||
|
||||
|
||||
#include "bitcoindjs.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace boost;
|
||||
using namespace node;
|
||||
|
@ -536,7 +534,9 @@ start_node_thread(void) {
|
|||
|
||||
detectShutdownThread = new boost::thread(
|
||||
boost::bind(&DetectShutdownThread, &threadGroup));
|
||||
|
||||
fRet = AppInit2(threadGroup);
|
||||
|
||||
} catch (std::exception& e) {
|
||||
if (set_cooked()) {
|
||||
fprintf(stderr, "bitcoind.js: AppInit(): std::exception\n");
|
||||
|
@ -572,6 +572,7 @@ start_node_thread(void) {
|
|||
*/
|
||||
|
||||
NAN_METHOD(StopBitcoind) {
|
||||
fprintf(stderr, "Stopping Bitcoind please wait!");
|
||||
Isolate* isolate = Isolate::GetCurrent();
|
||||
HandleScope scope(isolate);
|
||||
|
||||
|
@ -746,6 +747,7 @@ async_get_block(uv_work_t *req) {
|
|||
std::string strHash = data->hash;
|
||||
uint256 hash(strHash);
|
||||
CBlock cblock;
|
||||
|
||||
CBlockIndex* pblockindex = mapBlockIndex[hash];
|
||||
|
||||
if (ReadBlockFromDisk(cblock, pblockindex)) {
|
||||
|
|
|
@ -159,7 +159,6 @@
|
|||
#define USE_LDB_ADDR 0
|
||||
#define USE_LDB_TX 0
|
||||
|
||||
#define SHUTTING_DOWN() (ShutdownRequested() || shutdown_complete)
|
||||
|
||||
/**
|
||||
* Node.js Exposed Function Templates
|
||||
|
|
Loading…
Reference in New Issue