Add a few comments
This commit is contained in:
11
src/index.ts
11
src/index.ts
@@ -22,40 +22,49 @@ export class App {
|
||||
static async create(genesisData: WalletHDWatchGenesisData) {
|
||||
const debug = Debug('xpub');
|
||||
|
||||
// Create the storage for the app.
|
||||
debug('Creating storage...');
|
||||
const storage = await StorageSQLite.createOrOpen('xpub-backend.sqlite');
|
||||
|
||||
// Create the blockchain cache for the app.
|
||||
debug('Creating blockchain cache...');
|
||||
const blockchainCache = await storage.createOrGetStore('blockchain', {
|
||||
syncInMemory: false
|
||||
});
|
||||
|
||||
// Create the wallet cache for the app.
|
||||
debug('Creating wallet cache...');
|
||||
const walletCache = await storage.createOrGetStore('wallet', {
|
||||
syncInMemory: false
|
||||
});
|
||||
|
||||
// Create the blockchain for the app.
|
||||
debug('Creating blockchain...');
|
||||
const blockchain = await BlockchainElectrum.from({
|
||||
store: blockchainCache,
|
||||
servers: [ 'cashnode.bch.ninja' ]
|
||||
});
|
||||
|
||||
// Create the wallet for the app.
|
||||
debug('Creating wallet...');
|
||||
const wallet = await WalletHDWatch.from({
|
||||
blockchain,
|
||||
cache: walletCache
|
||||
}, genesisData);
|
||||
|
||||
// Create the routes for the app.
|
||||
debug('Creating Routes...');
|
||||
const routes = new WalletRoutes(wallet);
|
||||
|
||||
// Create the router for the app.
|
||||
debug('Creating Router...');
|
||||
const router = new HTTPService({ routes: [routes], debug });
|
||||
|
||||
// Create the app.
|
||||
debug('Creating App...');
|
||||
const app = new App({ blockchain, wallet, httpService: router, debug });
|
||||
|
||||
// Start the app.
|
||||
await app.start();
|
||||
return app;
|
||||
|
||||
@@ -66,6 +75,7 @@ export class App {
|
||||
async start() {
|
||||
this.deps.debug('Starting app...');
|
||||
|
||||
// Start the following services in parallel as they have no dependency on each other.
|
||||
await Promise.all([
|
||||
// Start the blockchain
|
||||
this.deps.blockchain.start()
|
||||
@@ -80,6 +90,7 @@ export class App {
|
||||
.then(() => this.deps.debug('Router started')),
|
||||
]);
|
||||
|
||||
// Log the current RAM usage.
|
||||
this.deps.debug(`Current RAM usage: ${getCurrentRamUsage()} MB`);
|
||||
this.deps.debug('App started');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user