This repository has been archived by the owner on Dec 4, 2018. It is now read-only.
forked from jb55/node-bitcoin
-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
476 additions
and
465 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,58 @@ | ||
var commands = require('./commands'), | ||
rpc = require('./jsonrpc'); | ||
var commands = require('./commands') | ||
var rpc = require('./jsonrpc') | ||
|
||
//===----------------------------------------------------------------------===// | ||
// ===----------------------------------------------------------------------===// | ||
// Client | ||
//===----------------------------------------------------------------------===// | ||
function Client(opts) { | ||
this.rpc = new rpc.Client(opts); | ||
// ===----------------------------------------------------------------------===// | ||
function Client (opts) { | ||
this.rpc = new rpc.Client(opts) | ||
} | ||
|
||
|
||
//===----------------------------------------------------------------------===// | ||
// ===----------------------------------------------------------------------===// | ||
// cmd | ||
//===----------------------------------------------------------------------===// | ||
Client.prototype.cmd = function() { | ||
var args = [].slice.call(arguments); | ||
var cmd = args.shift(); | ||
// ===----------------------------------------------------------------------===// | ||
Client.prototype.cmd = function () { | ||
var args = [].slice.call(arguments) | ||
var cmd = args.shift() | ||
|
||
callRpc(cmd, args, this.rpc); | ||
callRpc(cmd, args, this.rpc) | ||
} | ||
|
||
|
||
//===----------------------------------------------------------------------===// | ||
// ===----------------------------------------------------------------------===// | ||
// callRpc | ||
//===----------------------------------------------------------------------===// | ||
function callRpc(cmd, args, rpc) { | ||
var fn = args[args.length-1]; | ||
// ===----------------------------------------------------------------------===// | ||
function callRpc (cmd, args, rpc) { | ||
var fn = args[args.length - 1] | ||
|
||
// If the last argument is a callback, pop it from the args list | ||
if (typeof fn === 'function') { | ||
args.pop(); | ||
args.pop() | ||
} else { | ||
fn = function() {}; | ||
fn = function () {} | ||
} | ||
|
||
rpc.call(cmd, args, function(){ | ||
var args = [].slice.call(arguments); | ||
args.unshift(null); | ||
fn.apply(this, args); | ||
}, function(err){ | ||
fn(err); | ||
}); | ||
rpc.call(cmd, args, function () { | ||
var args = [].slice.call(arguments) | ||
args.unshift(null) | ||
fn.apply(this, args) | ||
}, function (err) { | ||
fn(err) | ||
}) | ||
} | ||
|
||
//===----------------------------------------------------------------------===// | ||
// ===----------------------------------------------------------------------===// | ||
// Initialize wrappers | ||
//===----------------------------------------------------------------------===// | ||
(function() { | ||
|
||
// ===----------------------------------------------------------------------===// | ||
(function () { | ||
for (var protoFn in commands) { | ||
(function(protoFn) { | ||
Client.prototype[protoFn] = function() { | ||
var args = [].slice.call(arguments); | ||
callRpc(commands[protoFn], args, this.rpc); | ||
}; | ||
})(protoFn); | ||
(function (protoFn) { | ||
Client.prototype[protoFn] = function () { | ||
var args = [].slice.call(arguments) | ||
callRpc(commands[protoFn], args, this.rpc) | ||
} | ||
})(protoFn) | ||
} | ||
|
||
})(); | ||
})() | ||
|
||
// Export! | ||
module.exports.Client = Client; | ||
module.exports.Client = Client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.