Handle accelerations in v1 audit
This commit is contained in:
		
							parent
							
								
									67761230e3
								
							
						
					
					
						commit
						b9334c93f5
					
				@ -21,6 +21,7 @@ class Audit {
 | 
				
			|||||||
    const accelerated: string[] = []; // prioritized by the mempool accelerator
 | 
					    const accelerated: string[] = []; // prioritized by the mempool accelerator
 | 
				
			||||||
    const isCensored = {}; // missing, without excuse
 | 
					    const isCensored = {}; // missing, without excuse
 | 
				
			||||||
    const isDisplaced = {};
 | 
					    const isDisplaced = {};
 | 
				
			||||||
 | 
					    const isAccelerated = {};
 | 
				
			||||||
    let displacedWeight = 0;
 | 
					    let displacedWeight = 0;
 | 
				
			||||||
    let matchedWeight = 0;
 | 
					    let matchedWeight = 0;
 | 
				
			||||||
    let projectedWeight = 0;
 | 
					    let projectedWeight = 0;
 | 
				
			||||||
@ -33,6 +34,7 @@ class Audit {
 | 
				
			|||||||
      inBlock[tx.txid] = tx;
 | 
					      inBlock[tx.txid] = tx;
 | 
				
			||||||
      if (mempool[tx.txid] && mempool[tx.txid].acceleration) {
 | 
					      if (mempool[tx.txid] && mempool[tx.txid].acceleration) {
 | 
				
			||||||
        accelerated.push(tx.txid);
 | 
					        accelerated.push(tx.txid);
 | 
				
			||||||
 | 
					        isAccelerated[tx.txid] = true;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    // coinbase is always expected
 | 
					    // coinbase is always expected
 | 
				
			||||||
@ -143,7 +145,8 @@ class Audit {
 | 
				
			|||||||
      // so exclude from the analysis.
 | 
					      // so exclude from the analysis.
 | 
				
			||||||
      if ((blockTx.effectiveFeePerVsize || 0) < lastEffectiveRate) {
 | 
					      if ((blockTx.effectiveFeePerVsize || 0) < lastEffectiveRate) {
 | 
				
			||||||
        prioritized.push(blockTx.txid);
 | 
					        prioritized.push(blockTx.txid);
 | 
				
			||||||
      } else {
 | 
					        // accelerated txs may or may not have their prioritized fee rate applied, so don't use them as a reference
 | 
				
			||||||
 | 
					      } else if (!isAccelerated[blockTx.txid]) {
 | 
				
			||||||
        lastEffectiveRate = blockTx.effectiveFeePerVsize || 0;
 | 
					        lastEffectiveRate = blockTx.effectiveFeePerVsize || 0;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
@ -33,6 +33,7 @@ import AccelerationRepository from '../repositories/AccelerationRepository';
 | 
				
			|||||||
import { calculateFastBlockCpfp, calculateGoodBlockCpfp } from './cpfp';
 | 
					import { calculateFastBlockCpfp, calculateGoodBlockCpfp } from './cpfp';
 | 
				
			||||||
import mempool from './mempool';
 | 
					import mempool from './mempool';
 | 
				
			||||||
import CpfpRepository from '../repositories/CpfpRepository';
 | 
					import CpfpRepository from '../repositories/CpfpRepository';
 | 
				
			||||||
 | 
					import accelerationApi from './services/acceleration';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Blocks {
 | 
					class Blocks {
 | 
				
			||||||
  private blocks: BlockExtended[] = [];
 | 
					  private blocks: BlockExtended[] = [];
 | 
				
			||||||
@ -904,7 +905,12 @@ class Blocks {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      const cpfpSummary: CpfpSummary = calculateGoodBlockCpfp(block.height, transactions, Object.values(mempool.getAccelerations()).map(a => ({ txid: a.txid, max_bid: a.feeDelta })));
 | 
					      let accelerations = Object.values(mempool.getAccelerations());
 | 
				
			||||||
 | 
					      if (accelerations?.length > 0) {
 | 
				
			||||||
 | 
					        const pool = await this.$findBlockMiner(transactionUtils.stripCoinbaseTransaction(transactions[0]));
 | 
				
			||||||
 | 
					        accelerations = accelerations.filter(a => a.pools.includes(pool.uniqueId));
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      const cpfpSummary: CpfpSummary = calculateGoodBlockCpfp(block.height, transactions, accelerations.map(a => ({ txid: a.txid, max_bid: a.feeDelta })));
 | 
				
			||||||
      const blockExtended: BlockExtended = await this.$getBlockExtended(block, cpfpSummary.transactions);
 | 
					      const blockExtended: BlockExtended = await this.$getBlockExtended(block, cpfpSummary.transactions);
 | 
				
			||||||
      const blockSummary: BlockSummary = this.summarizeBlockTransactions(block.id, cpfpSummary.transactions);
 | 
					      const blockSummary: BlockSummary = this.summarizeBlockTransactions(block.id, cpfpSummary.transactions);
 | 
				
			||||||
      this.updateTimerProgress(timer, `got block data for ${this.currentBlockHeight}`);
 | 
					      this.updateTimerProgress(timer, `got block data for ${this.currentBlockHeight}`);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user