From 1d6bd6dbe45691828e5786a497d2a9f254595964 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Tue, 14 Mar 2017 06:22:43 -0700 Subject: [PATCH] node: require walletdb by default for now. --- bin/node | 5 +++++ bin/spvnode | 5 +++++ lib/node/node.js | 14 ++++++++++---- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/bin/node b/bin/node index eebd3d30..f5627261 100755 --- a/bin/node +++ b/bin/node @@ -5,6 +5,7 @@ process.title = 'bcoin'; var bcoin = require('../'); +var plugin = require('../lib/wallet/plugin'); var co = bcoin.co; var node; @@ -21,6 +22,10 @@ node = new bcoin.fullnode({ loader: require }); +// Temporary hack +if (!node.has('walletdb')) + node.use(plugin); + node.on('error', function(err) { ; }); diff --git a/bin/spvnode b/bin/spvnode index de52af6b..1b61222b 100755 --- a/bin/spvnode +++ b/bin/spvnode @@ -6,6 +6,7 @@ process.title = 'bcoin'; var assert = require('assert'); var bcoin = require('../'); +var plugin = require('../lib/wallet/plugin'); var util = bcoin.util; var co = bcoin.co; var node; @@ -23,6 +24,10 @@ node = bcoin.spvnode({ loader: require }); +// Temporary hack +if (!node.has('walletdb')) + node.use(plugin); + node.on('error', function(err) { ; }); diff --git a/lib/node/node.js b/lib/node/node.js index 0be2247d..b0237fa3 100644 --- a/lib/node/node.js +++ b/lib/node/node.js @@ -314,6 +314,16 @@ Node.prototype.use = function use(plugin) { return instance; }; +/** + * Test whether a plugin is available. + * @param {String} name + * @returns {Boolean} + */ + +Node.prototype.has = function has(name) { + return this.plugins[name] != null; +}; + /** * Require a plugin. * @param {String} name @@ -371,10 +381,6 @@ Node.prototype.loadPlugins = function loadPlugins() { assert(typeof name === 'string', 'Plugin name must be a string.'); - // Temporary until we separate walletdb out. - if (name === 'walletdb') - name = __dirname + '/../wallet/plugin'; - plugin = loader(name); this.use(plugin);