Skip to content
Snippets Groups Projects
Commit c51a2db8 authored by Robert Martin-Legene's avatar Robert Martin-Legene
Browse files

Algunos bugs

parent b8fd8d9f
No related branches found
No related tags found
No related merge requests found
...@@ -97,25 +97,23 @@ module.exports = class Libbfa ...@@ -97,25 +97,23 @@ module.exports = class Libbfa
var w3 = new this.Web3( this.provider ); var w3 = new this.Web3( this.provider );
var req_url = this.req_url; var req_url = this.req_url;
var _bfa = this; var _bfa = this;
// This could just remain the same number all the time.
var unneededcounter = 1;
w3.jsonify = function( opname, params ) w3.jsonify = function( opname, params )
{ {
var extra = params.join(','); var obj = {};
return JSON.parse( obj.id = unneededcounter++;
'{'+ obj.jsonrpc = "2.0";
'"jsonrpc":"2.0",' + obj.method = opname;
'"id":1,' + obj.params = params;
'"method":"' + opname + '",' + return obj;
'"params":[' + extra + ']' +
'}'
);
}; };
w3.rpcreq = function( opname, params, callback ) w3.rpcreq = function( opname, params, callback )
{ {
var body = w3.jsonify( opname, params );
request.post({ request.post({
uri: req_url, uri: req_url,
json: true, json: true,
body: body, body: w3.jsonify( opname, params ),
callback: function RPCresponse( err, obj ) callback: function RPCresponse( err, obj )
{ {
var r; var r;
...@@ -154,7 +152,7 @@ module.exports = class Libbfa ...@@ -154,7 +152,7 @@ module.exports = class Libbfa
// in a TCP stream . // in a TCP stream .
// Writes out data and closes our end of the connection. // Writes out data and closes our end of the connection.
// Geth will reply and then close it's end. // Geth will reply and then close it's end.
s.end( w3.jsonify(opname,params) ); socket.end( w3.jsonify(opname,params).valueOf() );
}); });
socket.on("data", (d) => { socket.on("data", (d) => {
try { try {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment