2016-02-14 18:05:21 -08:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
|
2016-06-13 01:06:01 -07:00
|
|
|
'use strict';
|
|
|
|
|
|
2016-07-30 13:53:43 -07:00
|
|
|
process.title = 'bcoin';
|
|
|
|
|
|
2017-05-12 11:44:08 -07:00
|
|
|
if (process.argv.indexOf('--help') !== -1
|
|
|
|
|
|| process.argv.indexOf('-h') !== -1) {
|
|
|
|
|
console.error('See the bcoin wiki at: https://github.com/bcoin-org/bcoin/wiki.');
|
|
|
|
|
process.exit(1);
|
|
|
|
|
throw new Error('Could not exit.');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (process.argv.indexOf('--version') !== -1
|
|
|
|
|
|| process.argv.indexOf('-v') !== -1) {
|
|
|
|
|
var pkg = require('../package.json');
|
|
|
|
|
console.log(pkg.version);
|
|
|
|
|
process.exit(0);
|
|
|
|
|
throw new Error('Could not exit.');
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-14 07:18:47 -08:00
|
|
|
var bcoin = require('../');
|
2017-03-14 06:22:43 -07:00
|
|
|
var plugin = require('../lib/wallet/plugin');
|
2017-01-14 07:18:47 -08:00
|
|
|
var co = bcoin.co;
|
2017-03-08 07:18:53 -08:00
|
|
|
var node;
|
2016-02-14 18:05:21 -08:00
|
|
|
|
2017-03-08 07:18:53 -08:00
|
|
|
node = new bcoin.fullnode({
|
2017-03-10 20:25:00 -08:00
|
|
|
config: true,
|
|
|
|
|
argv: true,
|
|
|
|
|
env: true,
|
2016-07-04 05:36:06 -07:00
|
|
|
logFile: true,
|
2017-03-14 05:16:52 -07:00
|
|
|
logConsole: true,
|
2017-03-08 07:18:53 -08:00
|
|
|
logLevel: 'debug',
|
2016-07-04 05:36:06 -07:00
|
|
|
db: 'leveldb',
|
2017-03-14 05:47:12 -07:00
|
|
|
persistent: true,
|
2017-03-08 07:18:53 -08:00
|
|
|
listen: true,
|
|
|
|
|
loader: require
|
2016-02-14 18:05:21 -08:00
|
|
|
});
|
|
|
|
|
|
2017-03-14 06:22:43 -07:00
|
|
|
// Temporary hack
|
2017-05-12 11:44:08 -07:00
|
|
|
if (!node.config.bool('no-wallet') && !node.has('walletdb'))
|
2017-03-14 06:22:43 -07:00
|
|
|
node.use(plugin);
|
|
|
|
|
|
2016-02-14 18:05:21 -08:00
|
|
|
node.on('error', function(err) {
|
2016-07-04 05:36:06 -07:00
|
|
|
;
|
2016-02-14 18:05:21 -08:00
|
|
|
});
|
2016-03-22 17:36:58 -07:00
|
|
|
|
2017-01-14 07:18:47 -08:00
|
|
|
co.spawn(function *() {
|
2017-03-14 05:47:12 -07:00
|
|
|
yield node.ensure();
|
2017-01-14 07:18:47 -08:00
|
|
|
yield node.open();
|
|
|
|
|
yield node.connect();
|
2016-07-29 15:40:39 -07:00
|
|
|
node.startSync();
|
2017-01-14 07:18:47 -08:00
|
|
|
}).catch(function(err) {
|
|
|
|
|
throw err;
|
2016-03-22 17:36:58 -07:00
|
|
|
});
|