Comparing version 0.2.2 to 0.2.3
32
index.js
@@ -12,2 +12,3 @@ /** | ||
var url = require("url"); | ||
var async = require("async"); | ||
var BigNumber = require("bignumber.js"); | ||
@@ -294,3 +295,3 @@ var request = (NODE_JS) ? require("sync-request") : null; | ||
broadcast: function (command, callback) { | ||
var i, j, num_nodes, num_commands, returns, result, complete; | ||
var i, j, self, loop, nodes, num_nodes, num_commands, returns, result; | ||
@@ -319,17 +320,16 @@ // make sure the ethereum node list isn't empty | ||
if (callback && callback.constructor === Function) { | ||
var self = this; | ||
command = JSON.stringify(command); | ||
num_nodes = this.nodes.length; | ||
for (j = 0; j < num_nodes; ++j) { | ||
(function (node) { | ||
self.post(node, command, returns, function (result) { | ||
if (result !== undefined && | ||
result !== "0x" && !result.error) | ||
{ | ||
if (!complete) callback(result); | ||
complete = true; | ||
} | ||
}); | ||
})(this.nodes[j]); | ||
} | ||
self = this; | ||
loop = (command.method === "eth_call") ? async.each : async.eachSeries; | ||
nodes = this.nodes.slice(); | ||
loop(nodes, function (node, nextNode) { | ||
self.post(node, JSON.stringify(command), returns, function (res) { | ||
if (node === nodes[nodes.length - 1]) { | ||
return nextNode(res); | ||
} | ||
if (res !== undefined && res !== null && !res.error) { | ||
return nextNode(res); | ||
} | ||
nextNode(); | ||
}); | ||
}, callback); | ||
@@ -336,0 +336,0 @@ // use synchronous http if no callback provided |
{ | ||
"name": "ethrpc", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"description": "Ethereum JSON RPC", | ||
@@ -22,2 +22,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"async": "^1.4.2", | ||
"augur-abi": "^0.1.1", | ||
@@ -24,0 +25,0 @@ "bignumber.js": "^2.0.7" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
1255420
25312
4
+ Addedasync@^1.4.2
+ Addedasync@1.5.2(transitive)