disable multiple instantiations.
This commit is contained in:
parent
e6e6dab798
commit
76f2d147a6
@ -24,6 +24,11 @@ function Bitcoin(options) {
|
|||||||
return new 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);
|
EventEmitter.call(this);
|
||||||
|
|
||||||
this.options = options || {};
|
this.options = options || {};
|
||||||
@ -46,12 +51,6 @@ function Bitcoin(options) {
|
|||||||
|
|
||||||
this.config = this.options.datadir + '/bitcoin.conf';
|
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)) {
|
if (!fs.existsSync(this.options.datadir)) {
|
||||||
mkdirp.sync(this.options.datadir);
|
mkdirp.sync(this.options.datadir);
|
||||||
}
|
}
|
||||||
@ -98,7 +97,7 @@ Bitcoin.instances = {};
|
|||||||
Bitcoin.prototype.instances = Bitcoin.instances;
|
Bitcoin.prototype.instances = Bitcoin.instances;
|
||||||
|
|
||||||
Bitcoin.__defineGetter__('global', function() {
|
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) {
|
Bitcoin.prototype.start = function(options, callback) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user