disable multiple instantiations.

This commit is contained in:
Christopher Jeffrey 2014-10-17 12:54:58 -07:00
parent e6e6dab798
commit 76f2d147a6

View File

@ -24,6 +24,11 @@ function Bitcoin(options) {
return new Bitcoin(options);
}
if (Object.keys(this.instances).length) {
throw new
Error('bitcoind.js cannot be instantiated more than once.');
}
EventEmitter.call(this);
this.options = options || {};
@ -46,12 +51,6 @@ function Bitcoin(options) {
this.config = this.options.datadir + '/bitcoin.conf';
if (this.instances[this.options.datadir]) {
throw new Error(''
+ 'bitcoind.js cannot be instantiated'
+ ' more than once on the same datadir.');
}
if (!fs.existsSync(this.options.datadir)) {
mkdirp.sync(this.options.datadir);
}
@ -98,7 +97,7 @@ Bitcoin.instances = {};
Bitcoin.prototype.instances = Bitcoin.instances;
Bitcoin.__defineGetter__('global', function() {
return Bitcoin.instances[process.env.HOME + '/.bitcoin'];
return Bitcoin.instances[Object.keys(Bitcoin.instances)[0]];
});
Bitcoin.prototype.start = function(options, callback) {