@@ -5,7 +5,7 @@ var bitcoin = require('bitcoin');
5
5
var async = require ( 'async' ) ;
6
6
var maxTime = 20 ;
7
7
8
- console . log ( 'Benchmarking Bitcoind.js native interface versus Bitcoind JSON RPC interface' ) ;
8
+ console . log ( 'Bitcoin Service native interface vs. Bitcoin JSON RPC interface' ) ;
9
9
console . log ( '----------------------------------------------------------------------' ) ;
10
10
11
11
// To run the benchmarks a fully synced Bitcore Core directory is needed. The RPC comands
@@ -26,22 +26,29 @@ var fixtureData = {
26
26
]
27
27
} ;
28
28
29
- var bitcoind = require ( '../' ) . daemon ( {
30
- datadir : process . env . BITCORENODE_DIR || '~/.bitcoin' ,
31
- network : 'testnet'
29
+ var bitcoind = require ( '../' ) . services . Bitcoin ( {
30
+ node : {
31
+ datadir : process . env . HOME + '/.bitcoin' ,
32
+ network : {
33
+ name : 'testnet'
34
+ }
35
+ }
32
36
} ) ;
33
37
34
38
bitcoind . on ( 'error' , function ( err ) {
35
- bitcoind . log ( ' error="%s"' , err . message ) ;
39
+ console . error ( err . message ) ;
36
40
} ) ;
37
41
38
- bitcoind . on ( 'open' , function ( status ) {
39
- bitcoind . log ( 'status="%s"' , status ) ;
42
+ bitcoind . start ( function ( err ) {
43
+ if ( err ) {
44
+ throw err ;
45
+ }
46
+ console . log ( 'Bitcoin Core started' ) ;
40
47
} ) ;
41
48
42
49
bitcoind . on ( 'ready' , function ( ) {
43
50
44
- bitcoind . log ( 'status="%s"' , 'chaintip ready. ') ;
51
+ console . log ( 'Bitcoin Core ready' ) ;
45
52
46
53
var client = new bitcoin . Client ( {
47
54
host : 'localhost' ,
@@ -147,8 +154,16 @@ bitcoind.on('ready', function() {
147
154
. run ( ) ;
148
155
}
149
156
] , function ( err ) {
157
+ if ( err ) {
158
+ throw err ;
159
+ }
150
160
console . log ( 'Finished' ) ;
151
- bitcoind . stop ( ) ;
152
- process . exit ( ) ;
161
+ bitcoind . stop ( function ( err ) {
162
+ if ( err ) {
163
+ console . error ( 'Fail to stop services: ' + err ) ;
164
+ process . exit ( 1 ) ;
165
+ }
166
+ process . exit ( 0 ) ;
167
+ } ) ;
153
168
} ) ;
154
169
} ) ;
0 commit comments