Browse Source

More parallel calls in tx processors

umbrel
Pavel Ševčík 4 years ago
parent
commit
31417c53e4
No known key found for this signature in database GPG Key ID: D3B8A90B4072D9DB
  1. 13
      tracker/blockchain-processor.js
  2. 5
      tracker/mempool-processor.js

13
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

5
tracker/mempool-processor.js

@ -257,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

Loading…
Cancel
Save