Comparing version 0.2.5 to 0.2.6
55
index.js
@@ -21,2 +21,9 @@ /** | ||
var NODES = [ | ||
"http://eth3.augur.net", | ||
"http://eth1.augur.net", | ||
"http://eth4.augur.net", | ||
"http://eth5.augur.net" | ||
]; | ||
module.exports = { | ||
@@ -38,8 +45,3 @@ | ||
nodes: [ | ||
"http://eth3.augur.net", | ||
"http://eth1.augur.net", | ||
"http://eth4.augur.net", | ||
"http://eth5.augur.net" | ||
], | ||
nodes: NODES, | ||
@@ -306,2 +308,3 @@ requests: 1, | ||
} | ||
nodes = this.nodes.slice(); | ||
@@ -323,12 +326,11 @@ // parse batched commands and strip "returns" fields | ||
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); | ||
nextNode(res); | ||
} else if (res !== undefined && res !== null && !res.error) { | ||
nextNode(res); | ||
} else { | ||
nextNode(); | ||
} | ||
if (res !== undefined && res !== null && !res.error) { | ||
return nextNode(res); | ||
} | ||
nextNode(); | ||
}); | ||
@@ -340,11 +342,12 @@ }, callback); | ||
if (!NODE_JS) command = JSON.stringify(command); | ||
num_nodes = this.nodes.length; | ||
num_nodes = nodes.length; | ||
for (j = 0; j < num_nodes; ++j) { | ||
try { | ||
result = this.postSync(this.nodes[j], command, returns); | ||
result = this.postSync(nodes[j], command, returns); | ||
} catch (e) { | ||
this.exciseNode(e, this.nodes[j], j--); | ||
this.exciseNode(e, nodes[j], j); | ||
} | ||
if (result && result !== "0x") return result; | ||
if (result) return result; | ||
} | ||
return null; | ||
} | ||
@@ -375,2 +378,7 @@ }, | ||
// reset to default Ethereum nodes | ||
reset: function () { | ||
this.nodes = NODES; | ||
}, | ||
/****************************** | ||
@@ -549,3 +557,3 @@ * Ethereum JSON-RPC bindings * | ||
tx.to = tx.to || ""; | ||
tx.gas = (tx.gas) ? abi.prefix_hex(tx.gas.toString(16)) : this.DEFAULT_GAS; | ||
tx.gas = (tx.gas) ? tx.gas : this.DEFAULT_GAS; | ||
return this.broadcast(this.marshal("call", tx), f); | ||
@@ -556,3 +564,3 @@ }, | ||
tx.to = tx.to || ""; | ||
tx.gas = (tx.gas) ? abi.prefix_hex(tx.gas.toString(16)) : this.DEFAULT_GAS; | ||
tx.gas = (tx.gas) ? tx.gas : this.DEFAULT_GAS; | ||
return this.broadcast(this.marshal("sendTransaction", tx), f); | ||
@@ -562,8 +570,7 @@ }, | ||
tx.to = tx.to || ""; | ||
tx.gas = (tx.gas) ? abi.prefix_hex(tx.gas.toString(16)) : this.DEFAULT_GAS; | ||
tx.gas = (tx.gas) ? tx.gas : this.DEFAULT_GAS; | ||
return this.broadcast(this.marshal("sendTransaction", tx), f); | ||
}, | ||
// IN: RLP(tx.signed(privateKey)) | ||
// OUT: txhash | ||
// sendRawTx(RLP(tx.signed(privateKey))) -> txhash | ||
sendRawTx: function (rawTx, f) { | ||
@@ -677,5 +684,7 @@ return this.broadcast(this.marshal("sendRawTransaction", rawTx), f); | ||
packaged = { | ||
from: tx.from || this.eth("coinbase"), | ||
from: tx.from || this.coinbase(), | ||
to: tx.to, | ||
data: data_abi | ||
data: data_abi, | ||
gas: tx.gas || this.DEFAULT_GAS, | ||
gasPrice: tx.gasPrice || this.gasPrice() | ||
}; | ||
@@ -682,0 +691,0 @@ if (tx.value) packaged.value = tx.value; |
{ | ||
"name": "ethrpc", | ||
"version": "0.2.5", | ||
"version": "0.2.6", | ||
"description": "Ethereum JSON RPC", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
1256868
25347