-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
285cd18
commit 693f00b
Showing
4 changed files
with
58 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
const bcash = require('bcash'); | ||
|
||
const FullNode = bcash.FullNode; | ||
|
||
let node; | ||
|
||
const startNode = (opts) => new Promise((resolve, reject) => { | ||
if (node) { | ||
return console.log("Node is already initialized."); | ||
} | ||
|
||
node = new FullNode({ | ||
file: true, | ||
argv: true, | ||
env: true, | ||
logFile: true, | ||
logConsole: opts.debug, | ||
logLevel: 'debug', | ||
|
||
// Start up a blockchain, mempool, and miner using in-memory | ||
// databases (stored in a red-black tree instead of on-disk). | ||
memory: true, | ||
network: "regtest", | ||
workers: true, | ||
listen: false, | ||
loader: require | ||
}); | ||
|
||
(async () => { | ||
await node.ensure(); | ||
await node.open(); | ||
await node.connect(); | ||
|
||
node.startSync(); | ||
|
||
resolve(node); | ||
})().catch((err) => { | ||
console.error(err.stack); | ||
|
||
reject(); | ||
}); | ||
}); | ||
|
||
module.exports = { | ||
startNode | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters