fix(default-config): update default config generation, include insight-api and insight-ui
This commit is contained in:
parent
7c65ebad27
commit
63c55689e8
@ -24,34 +24,47 @@ function getDefaultConfig(options) {
|
||||
mkdirp.sync(defaultPath);
|
||||
}
|
||||
|
||||
var defaultServices = ['bitcoind', 'db', 'address', 'web'];
|
||||
var defaultServices = [
|
||||
'address',
|
||||
'block',
|
||||
'db',
|
||||
'fee',
|
||||
'header',
|
||||
'mempool',
|
||||
'p2p',
|
||||
'timestamp',
|
||||
'transaction',
|
||||
'web'
|
||||
];
|
||||
|
||||
if (options.additionalServices) {
|
||||
defaultServices = defaultServices.concat(options.additionalServices);
|
||||
}
|
||||
|
||||
if (!fs.existsSync(defaultConfigFile)) {
|
||||
var defaultConfig = {
|
||||
network: 'livenet',
|
||||
port: 3001,
|
||||
services: defaultServices,
|
||||
servicesConfig: {
|
||||
bitcoind: {
|
||||
spawn: {
|
||||
datadir: path.resolve(defaultPath, './data'),
|
||||
exec: path.resolve(__dirname, '../../bin/bitcoind')
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
fs.writeFileSync(defaultConfigFile, JSON.stringify(defaultConfig, null, 2));
|
||||
}
|
||||
|
||||
var defaultDataDir = path.resolve(defaultPath, './data');
|
||||
|
||||
if (!fs.existsSync(defaultDataDir)) {
|
||||
mkdirp.sync(defaultDataDir);
|
||||
}
|
||||
|
||||
if (!fs.existsSync(defaultConfigFile)) {
|
||||
var defaultConfig = {
|
||||
network: 'testnet',
|
||||
port: 3001,
|
||||
services: defaultServices,
|
||||
datadir: defaultDataDir,
|
||||
servicesConfig: {
|
||||
'insight-api': {
|
||||
cwdRequirePath: 'node_modules/insight-api'
|
||||
},
|
||||
'insight-ui': {
|
||||
cwdRequirePath: 'node_modules/insight-ui'
|
||||
}
|
||||
}
|
||||
};
|
||||
fs.writeFileSync(defaultConfigFile, JSON.stringify(defaultConfig, null, 2));
|
||||
}
|
||||
|
||||
var config = JSON.parse(fs.readFileSync(defaultConfigFile, 'utf-8'));
|
||||
|
||||
return {
|
||||
|
||||
@ -86,10 +86,12 @@ function lookInRequirePathConfig(req, service) {
|
||||
}
|
||||
|
||||
function lookInCwd(req, service) {
|
||||
var location = service.config.cwdRequirePath ? service.config.cwdRequirePath : service.name
|
||||
try {
|
||||
return req(process.cwd + '/' + service);
|
||||
return req(process.cwd() + '/' + location);
|
||||
} catch(e) {
|
||||
log.info('Checked the current working directory for service: ' + service.name);
|
||||
if(e.code !== 'MODULE_NOT_FOUND') log.error(e);
|
||||
log.info('Checked the current working directory for service: ' + location);
|
||||
}
|
||||
}
|
||||
|
||||
@ -98,7 +100,7 @@ function lookInBuiltInPath(req, service) {
|
||||
var serviceFile = path.resolve(__dirname, '../services/' + service.name);
|
||||
return req(serviceFile);
|
||||
} catch(e) {
|
||||
console.log(e);
|
||||
if(e.code !== 'MODULE_NOT_FOUND') log.error(e);
|
||||
log.info('Checked the built-in path: lib/services, for service: ' + service.name);
|
||||
}
|
||||
}
|
||||
|
||||
@ -332,8 +332,9 @@ P2P.prototype._setResourceFilter = function(filter, resource) {
|
||||
};
|
||||
|
||||
P2P.prototype._startBcoin = function() {
|
||||
const network = ['livenet', 'live', 'main', 'mainnet'].indexOf(this.node.network) !== -1? 'main' : 'testnet'
|
||||
this._bcoin = new Bcoin({
|
||||
network: this.node.network,
|
||||
network: network,
|
||||
prefix: this.node.datadir
|
||||
});
|
||||
this._bcoin.start();
|
||||
|
||||
@ -51,7 +51,8 @@
|
||||
"async": "^2.5.0",
|
||||
"bcoin": "bcoin-org/bcoin#886008a1822ce1da7fa8395ee7db4bcc1750a28a",
|
||||
"bitcoind-rpc": "^0.6.0",
|
||||
"bitcore-lib": "^0.14",
|
||||
"bitcore-lib": "bitpay/bitcore-lib#transitional",
|
||||
"bitcore-p2p": "bitpay/bitcore-p2p#bcoin",
|
||||
"body-parser": "^1.13.3",
|
||||
"colors": "^1.1.2",
|
||||
"commander": "^2.8.1",
|
||||
@ -65,8 +66,7 @@
|
||||
"mkdirp": "0.5.0",
|
||||
"path-is-absolute": "^1.0.0",
|
||||
"socket.io": "^1.4.5",
|
||||
"socket.io-client": "^1.4.5",
|
||||
"bitcore-p2p": "bitpay/bitcore-p2p#bcoin"
|
||||
"socket.io-client": "^1.4.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"chai": "^3.5.0",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user