Comparing version 1.2.1 to 1.2.2
# node-bitcoin changelog | ||
## v1.2.2 (2012/04/26) | ||
Fix callback being called twice when a client and request error | ||
occur on the same command call. | ||
## v1.2.1 (2012/04/26) | ||
@@ -4,0 +8,0 @@ * Add missing `getBlock` command |
@@ -18,2 +18,3 @@ var util = require('util'); | ||
var client = http.createClient(port, host); | ||
var clientRequestErrorCalled = false; | ||
@@ -44,11 +45,12 @@ // First we encode the request into JSON | ||
request.write(requestJSON); | ||
function clientRequestErrorHandler(e) { | ||
if (!clientRequestErrorCalled) { | ||
clientRequestErrorCalled = true; | ||
errback(e); | ||
} | ||
} | ||
client.on('error', clientRequestErrorHandler); | ||
request.on('error', clientRequestErrorHandler); | ||
client.on('error', function(e){ | ||
errback(e); | ||
}); | ||
request.on('error', function(e){ | ||
errback(e); | ||
}); | ||
request.on('response', function(response) { | ||
@@ -55,0 +57,0 @@ // We need to buffer the response chunks in a nonblocking way. |
{ | ||
"name": "bitcoin", | ||
"description": "Communicate with bitcoind via JSON-RPC", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"main": "./lib/bitcoin", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
@@ -177,3 +177,19 @@ var path = require('path'); | ||
}, | ||
'creating a client on a non-listening port': { | ||
topic: function() { | ||
return new bitcoin.Client(config.host, 9897, 'baduser', 'badpwd'); | ||
}, | ||
'will return client object': function(client) { | ||
assert.equal(typeof client, 'object'); | ||
}, | ||
'but when calling a command': { | ||
topic: function(client) { | ||
client.listSinceBlock(this.callback); | ||
}, | ||
'should not call callback more than once': function(err, result) { | ||
assert.instanceOf(err, Error); | ||
} | ||
} | ||
} | ||
}).export(module); |
24666
542