organized commands to build from an array
This commit is contained in:
parent
e460bf915d
commit
2eb7712ab8
@ -3,8 +3,8 @@
|
||||
var bitcore = require('bitcore');
|
||||
|
||||
function builder(options) {
|
||||
/* jshint maxstatements: 50 */
|
||||
/* jshint maxcomplexity: 8 */
|
||||
/* jshint maxstatements: 20 */
|
||||
/* jshint maxcomplexity: 10 */
|
||||
|
||||
if (!options) {
|
||||
options = {};
|
||||
@ -20,8 +20,6 @@ function builder(options) {
|
||||
var MerkleBlock = options.MerkleBlock || bitcore.MerkleBlock;
|
||||
var protocolVersion = options.protocolVersion || 70000;
|
||||
|
||||
var commands = {};
|
||||
|
||||
var exported = {
|
||||
constructors: {
|
||||
Block: Block,
|
||||
@ -33,30 +31,19 @@ function builder(options) {
|
||||
protocolVersion: protocolVersion,
|
||||
magicNumber: magicNumber
|
||||
},
|
||||
commands: commands
|
||||
commands: {}
|
||||
};
|
||||
|
||||
commands.version = require('./commands/version')(options);
|
||||
commands.verack = require('./commands/verack')(options);
|
||||
commands.ping = require('./commands/ping')(options);
|
||||
commands.pong = require('./commands/pong')(options);
|
||||
commands.block = require('./commands/block')(options);
|
||||
commands.tx = require('./commands/tx')(options);
|
||||
commands.getdata = require('./commands/getdata')(options);
|
||||
commands.headers = require('./commands/headers')(options);
|
||||
commands.notfound = require('./commands/notfound')(options);
|
||||
commands.inv = require('./commands/inv')(options);
|
||||
commands.addr = require('./commands/addr')(options);
|
||||
commands.alert = require('./commands/alert')(options);
|
||||
commands.reject = require('./commands/reject')(options);
|
||||
commands.merkleblock = require('./commands/merkleblock')(options);
|
||||
commands.filterload = require('./commands/filterload')(options);
|
||||
commands.filteradd = require('./commands/filteradd')(options);
|
||||
commands.filterclear = require('./commands/filterclear')(options);
|
||||
commands.getblocks = require('./commands/getblocks')(options);
|
||||
commands.getheaders = require('./commands/getheaders')(options);
|
||||
commands.mempool = require('./commands/mempool')(options);
|
||||
commands.getaddr = require('./commands/getaddr')(options);
|
||||
var commandsArray = [
|
||||
'version', 'verack', 'ping', 'pong', 'block', 'tx', 'getdata', 'headers', 'notfound',
|
||||
'inv', 'addr', 'alert', 'reject', 'merkleblock', 'filterload', 'filteradd', 'filterclear',
|
||||
'getblocks', 'getheaders', 'mempool', 'getaddr'
|
||||
];
|
||||
|
||||
for (var i = 0; i < commandsArray.length; i++) {
|
||||
var command = commandsArray[i];
|
||||
exported.commands[command] = require('./commands/' + command)(options);
|
||||
}
|
||||
|
||||
return exported;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user