61 lines
1.2 KiB
JavaScript
Executable File
61 lines
1.2 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
|
|
'use strict';
|
|
|
|
process.title = 'fcoin';
|
|
|
|
if (process.argv.indexOf('--help') !== -1
|
|
|| process.argv.indexOf('-h') !== -1) {
|
|
console.error('See the bcoin docs at: https://github.com/bcoin-org/bcoin/tree/master/docs.');
|
|
process.exit(1);
|
|
throw new Error('Could not exit.');
|
|
}
|
|
|
|
if (process.argv.indexOf('--version') !== -1
|
|
|| process.argv.indexOf('-v') !== -1) {
|
|
const pkg = require('../package.json');
|
|
console.log(pkg.version);
|
|
process.exit(0);
|
|
throw new Error('Could not exit.');
|
|
}
|
|
|
|
const FullNode = require('../lib/node/fullnode');
|
|
|
|
const node = new FullNode({
|
|
file: true,
|
|
argv: true,
|
|
env: true,
|
|
logFile: true,
|
|
logConsole: true,
|
|
logLevel: 'debug',
|
|
checkpoints: true,
|
|
memory: false,
|
|
workers: true,
|
|
listen: true,
|
|
loader: require
|
|
});
|
|
|
|
// Temporary hack
|
|
if (!node.config.bool('no-wallet') && !node.has('walletdb')) {
|
|
const plugin = require('../lib/wallet/plugin');
|
|
node.use(plugin);
|
|
}
|
|
|
|
process.on('unhandledRejection', (err, promise) => {
|
|
throw err;
|
|
});
|
|
|
|
process.on('SIGINT', async () => {
|
|
await node.close();
|
|
});
|
|
|
|
(async () => {
|
|
await node.ensure();
|
|
await node.open();
|
|
await node.connect();
|
|
node.startSync();
|
|
})().catch((err) => {
|
|
console.error(err.stack);
|
|
process.exit(1);
|
|
});
|