diff --git a/lib/bitcoin/hd-accounts-service.js b/lib/bitcoin/hd-accounts-service.js index 63c3307..4de9787 100644 --- a/lib/bitcoin/hd-accounts-service.js +++ b/lib/bitcoin/hd-accounts-service.js @@ -144,10 +144,7 @@ class HDAccountsService { const externalPrm = hdaHelper.deriveAddresses(xpub, 0, _.range(gap.external), scheme) const internalPrm = hdaHelper.deriveAddresses(xpub, 1, _.range(gap.internal), scheme) - const external = await externalPrm - const internal = await internalPrm - - const addresses = _.flatten([external, internal]) + const addresses = _.flatten(await Promise.all([externalPrm, internalPrm])) return db.addAddressesToHDAccount(xpub, addresses) } diff --git a/lib/wallet/wallet-service.js b/lib/wallet/wallet-service.js index 8a09400..08cb7ad 100644 --- a/lib/wallet/wallet-service.js +++ b/lib/wallet/wallet-service.js @@ -365,10 +365,7 @@ class WalletService { */ _mergeEntities(active, legacy, bip49, bip84, pubkeys) { // Put all xpub into active.xpubs - active.xpubs = active.xpubs - .concat(legacy.xpubs) - .concat(bip49.xpubs) - .concat(bip84.xpubs) + active.xpubs = active.xpubs.concat(legacy.xpubs, bip49.xpubs, bip84.xpubs) // Put addresses and pubkeys into active // but avoid duplicates diff --git a/pushtx/status.js b/pushtx/status.js index 918bfb0..ec60a0e 100644 --- a/pushtx/status.js +++ b/pushtx/status.js @@ -75,8 +75,7 @@ class Status { this.status.push.count = this.stats.count try { - await this._refreshNetworkInfo() - await this._refreshBlockchainInfo() + await Promise.all([this._refreshNetworkInfo(), this._refreshBlockchainInfo()]) } catch (e) { Logger.error(e, 'PushTx : Status.getCurrent() : Error') } finally { diff --git a/tracker/blockchain-processor.js b/tracker/blockchain-processor.js index f0ee571..78e0d50 100644 --- a/tracker/blockchain-processor.js +++ b/tracker/blockchain-processor.js @@ -55,8 +55,7 @@ class BlockchainProcessor extends AbstractProcessor { * @returns {Promise} */ async catchup() { - const highest = await db.getHighestBlock() - const info = await this.client.getblockchaininfo() + const [highest, info] = await Promise.all([db.getHighestBlock(), this.client.getblockchaininfo()]) const daemonNbHeaders = info.headers // Consider that we are in IBD mode if Dojo is far in the past (> 13,000 blocks) @@ -80,12 +79,11 @@ class BlockchainProcessor extends AbstractProcessor { try { Logger.info('Tracker : Tracker Startup (IBD mode)') - const info = await this.client.getblockchaininfo() + // Get highest block processed by the tracker + const [highest, info] = await Promise.all([db.getHighestBlock(), this.client.getblockchaininfo()]) const daemonNbBlocks = info.blocks const daemonNbHeaders = info.headers - // Get highest block processed by the tracker - const highest = await db.getHighestBlock() const dbMaxHeight = highest.blockHeight let prevBlockId = highest.blockID @@ -151,11 +149,10 @@ class BlockchainProcessor extends AbstractProcessor { try { Logger.info('Tracker : Tracker Startup (normal mode)') - const info = await this.client.getblockchaininfo() + // Get highest block processed by the tracker + const [highest, info] = await Promise.all([db.getHighestBlock(), this.client.getblockchaininfo()]) const daemonNbBlocks = info.blocks - // Get highest block processed by the tracker - const highest = await db.getHighestBlock() if (highest == null) return null if (daemonNbBlocks == highest.blockHeight) return null diff --git a/tracker/mempool-processor.js b/tracker/mempool-processor.js index e3f7b00..17f8bf2 100644 --- a/tracker/mempool-processor.js +++ b/tracker/mempool-processor.js @@ -75,9 +75,11 @@ class MempoolProcessor extends AbstractProcessor { clearInterval(this.processMempoolId) //clearInterval(this.displayStatsId) - resolve(this.txSock.disconnect(keys.bitcoind.zmqTx).close()) - resolve(this.pushTxSock.disconnect(keys.ports.notifpushtx).close()) - resolve(this.orchestratorSock.disconnect(keys.ports.orchestrator).close()) + this.txSock.disconnect(keys.bitcoind.zmqTx).close() + this.pushTxSock.disconnect(keys.ports.notifpushtx).close() + this.orchestratorSock.disconnect(keys.ports.orchestrator).close() + + return Promise.resolve(); } /** @@ -255,11 +257,10 @@ class MempoolProcessor extends AbstractProcessor { */ async _refreshActiveStatus() { // Get highest header in the blockchain - const info = await this.client.getblockchaininfo() + // Get highest block processed by the tracker + const [highestBlock, info] = await Promise.all([db.getHighestBlock(), this.client.getblockchaininfo()]) const highestHeader = info.headers - // Get highest block processed by the tracker - const highestBlock = await db.getHighestBlock() if (highestBlock == null || highestBlock.blockHeight == 0) { this.isActive = false return