Skip to content

Commit 4d780a9

Browse files
committed
bitcoind: separate function for relative datadir expanding
1 parent 8145769 commit 4d780a9

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

lib/services/bitcoind.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -313,19 +313,23 @@ Bitcoin.prototype._parseBitcoinConf = function(configPath) {
313313
return options;
314314
};
315315

316+
Bitcoin.prototype._expandRelativeDatadir = function() {
317+
if (!utils.isAbsolutePath(this.options.spawn.datadir)) {
318+
$.checkState(this.node.configPath);
319+
$.checkState(utils.isAbsolutePath(this.node.configPath));
320+
var baseConfigPath = path.dirname(this.node.configPath);
321+
this.options.spawn.datadir = path.resolve(baseConfigPath, this.options.spawn.datadir);
322+
}
323+
};
324+
316325
Bitcoin.prototype._loadSpawnConfiguration = function(node) {
317326
/* jshint maxstatements: 25 */
318327

319328
$.checkArgument(this.options.spawn, 'Please specify "spawn" in bitcoind config options');
320329
$.checkArgument(this.options.spawn.datadir, 'Please specify "spawn.datadir" in bitcoind config options');
321330
$.checkArgument(this.options.spawn.exec, 'Please specify "spawn.exec" in bitcoind config options');
322331

323-
if (!utils.isAbsolutePath(this.options.spawn.datadir)) {
324-
$.checkState(this.node.configPath);
325-
$.checkState(utils.isAbsolutePath(this.node.configPath));
326-
var baseConfigPath = path.dirname(this.node.configPath);
327-
this.options.spawn.datadir = path.resolve(baseConfigPath, this.options.spawn.datadir);
328-
}
332+
this._expandRelativeDatadir();
329333

330334
var spawnOptions = this.options.spawn;
331335
var configPath = path.resolve(spawnOptions.datadir, './bitcoin.conf');

0 commit comments

Comments
 (0)