More conservative mempool inSync status
This commit is contained in:
		
							parent
							
								
									e59c961f25
								
							
						
					
					
						commit
						de4265a6d1
					
				@ -124,7 +124,7 @@ class Mempool {
 | 
				
			|||||||
          } else {
 | 
					          } else {
 | 
				
			||||||
            done = true;
 | 
					            done = true;
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
          if (count < expectedCount) {
 | 
					          if (Math.floor(count / expectedCount) < 1) {
 | 
				
			||||||
            loadingIndicators.setProgress('mempool', count / expectedCount * 100);
 | 
					            loadingIndicators.setProgress('mempool', count / expectedCount * 100);
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
@ -199,6 +199,7 @@ class Mempool {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    let loaded = false;
 | 
					    let loaded = false;
 | 
				
			||||||
    if (config.MEMPOOL.BACKEND === 'esplora' && currentMempoolSize < transactions.length * 0.5 && transactions.length > 20_000) {
 | 
					    if (config.MEMPOOL.BACKEND === 'esplora' && currentMempoolSize < transactions.length * 0.5 && transactions.length > 20_000) {
 | 
				
			||||||
 | 
					      this.inSync = false;
 | 
				
			||||||
      logger.info(`Missing ${transactions.length - currentMempoolSize} mempool transactions, attempting to reload in bulk from esplora`);
 | 
					      logger.info(`Missing ${transactions.length - currentMempoolSize} mempool transactions, attempting to reload in bulk from esplora`);
 | 
				
			||||||
      try {
 | 
					      try {
 | 
				
			||||||
        await this.$reloadMempool(transactions.length);
 | 
					        await this.$reloadMempool(transactions.length);
 | 
				
			||||||
@ -293,12 +294,6 @@ class Mempool {
 | 
				
			|||||||
    const newTransactionsStripped = newTransactions.map((tx) => Common.stripTransaction(tx));
 | 
					    const newTransactionsStripped = newTransactions.map((tx) => Common.stripTransaction(tx));
 | 
				
			||||||
    this.latestTransactions = newTransactionsStripped.concat(this.latestTransactions).slice(0, 6);
 | 
					    this.latestTransactions = newTransactionsStripped.concat(this.latestTransactions).slice(0, 6);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!this.inSync && transactions.length === newMempoolSize) {
 | 
					 | 
				
			||||||
      this.inSync = true;
 | 
					 | 
				
			||||||
      logger.notice('The mempool is now in sync!');
 | 
					 | 
				
			||||||
      loadingIndicators.setProgress('mempool', 100);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    this.mempoolCacheDelta = Math.abs(transactions.length - newMempoolSize);
 | 
					    this.mempoolCacheDelta = Math.abs(transactions.length - newMempoolSize);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (this.mempoolChangedCallback && (hasChange || deletedTransactions.length)) {
 | 
					    if (this.mempoolChangedCallback && (hasChange || deletedTransactions.length)) {
 | 
				
			||||||
@ -310,6 +305,12 @@ class Mempool {
 | 
				
			|||||||
      this.updateTimerProgress(timer, 'completed async mempool callback');
 | 
					      this.updateTimerProgress(timer, 'completed async mempool callback');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (!this.inSync && transactions.length === newMempoolSize) {
 | 
				
			||||||
 | 
					      this.inSync = true;
 | 
				
			||||||
 | 
					      logger.notice('The mempool is now in sync!');
 | 
				
			||||||
 | 
					      loadingIndicators.setProgress('mempool', 100);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const end = new Date().getTime();
 | 
					    const end = new Date().getTime();
 | 
				
			||||||
    const time = end - start;
 | 
					    const time = end - start;
 | 
				
			||||||
    logger.debug(`Mempool updated in ${time / 1000} seconds. New size: ${Object.keys(this.mempoolCache).length} (${diff > 0 ? '+' + diff : diff})`);
 | 
					    logger.debug(`Mempool updated in ${time / 1000} seconds. New size: ${Object.keys(this.mempoolCache).length} (${diff > 0 ? '+' + diff : diff})`);
 | 
				
			||||||
 | 
				
			|||||||
@ -644,7 +644,7 @@ class WebsocketHandler {
 | 
				
			|||||||
    memPool.handleMinedRbfTransactions(rbfTransactions);
 | 
					    memPool.handleMinedRbfTransactions(rbfTransactions);
 | 
				
			||||||
    memPool.removeFromSpendMap(transactions);
 | 
					    memPool.removeFromSpendMap(transactions);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (config.MEMPOOL.AUDIT) {
 | 
					    if (config.MEMPOOL.AUDIT && memPool.isInSync()) {
 | 
				
			||||||
      let projectedBlocks;
 | 
					      let projectedBlocks;
 | 
				
			||||||
      let auditMempool = _memPool;
 | 
					      let auditMempool = _memPool;
 | 
				
			||||||
      // template calculation functions have mempool side effects, so calculate audits using
 | 
					      // template calculation functions have mempool side effects, so calculate audits using
 | 
				
			||||||
@ -665,7 +665,7 @@ class WebsocketHandler {
 | 
				
			|||||||
        projectedBlocks = mempoolBlocks.getMempoolBlocksWithTransactions();
 | 
					        projectedBlocks = mempoolBlocks.getMempoolBlocksWithTransactions();
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if (Common.indexingEnabled() && memPool.isInSync()) {
 | 
					      if (Common.indexingEnabled()) {
 | 
				
			||||||
        const { censored, added, fresh, sigop, fullrbf, score, similarity } = Audit.auditBlock(transactions, projectedBlocks, auditMempool);
 | 
					        const { censored, added, fresh, sigop, fullrbf, score, similarity } = Audit.auditBlock(transactions, projectedBlocks, auditMempool);
 | 
				
			||||||
        const matchRate = Math.round(score * 100 * 100) / 100;
 | 
					        const matchRate = Math.round(score * 100 * 100) / 100;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user