Backend support for multi-pool acceleration details
This commit is contained in:
		
							parent
							
								
									05b022dec8
								
							
						
					
					
						commit
						1498db3b33
					
				| @ -160,7 +160,8 @@ class BitcoinRoutes { | |||||||
|           effectiveFeePerVsize: tx.effectiveFeePerVsize || null, |           effectiveFeePerVsize: tx.effectiveFeePerVsize || null, | ||||||
|           sigops: tx.sigops, |           sigops: tx.sigops, | ||||||
|           adjustedVsize: tx.adjustedVsize, |           adjustedVsize: tx.adjustedVsize, | ||||||
|           acceleration: tx.acceleration |           acceleration: tx.acceleration, | ||||||
|  |           acceleratedBy: tx.acceleratedBy || undefined, | ||||||
|         }); |         }); | ||||||
|         return; |         return; | ||||||
|       } |       } | ||||||
|  | |||||||
| @ -6,6 +6,7 @@ import config from '../config'; | |||||||
| import { Worker } from 'worker_threads'; | import { Worker } from 'worker_threads'; | ||||||
| import path from 'path'; | import path from 'path'; | ||||||
| import mempool from './mempool'; | import mempool from './mempool'; | ||||||
|  | import { Acceleration } from './services/acceleration'; | ||||||
| 
 | 
 | ||||||
| const MAX_UINT32 = Math.pow(2, 32) - 1; | const MAX_UINT32 = Math.pow(2, 32) - 1; | ||||||
| 
 | 
 | ||||||
| @ -333,7 +334,7 @@ class MempoolBlocks { | |||||||
|     } |     } | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   private processBlockTemplates(mempool: { [txid: string]: MempoolTransactionExtended }, blocks: string[][], blockWeights: number[] | null, rates: [string, number][], clusters: string[][], candidates: GbtCandidates | undefined, accelerations, accelerationPool, saveResults): MempoolBlockWithTransactions[] { |   private processBlockTemplates(mempool: { [txid: string]: MempoolTransactionExtended }, blocks: string[][], blockWeights: number[] | null, rates: [string, number][], clusters: string[][], candidates: GbtCandidates | undefined, accelerations: { [txid: string]: Acceleration }, accelerationPool, saveResults): MempoolBlockWithTransactions[] { | ||||||
|     for (const txid of Object.keys(candidates?.txs ?? mempool)) { |     for (const txid of Object.keys(candidates?.txs ?? mempool)) { | ||||||
|       if (txid in mempool) { |       if (txid in mempool) { | ||||||
|         mempool[txid].cpfpDirty = false; |         mempool[txid].cpfpDirty = false; | ||||||
| @ -396,7 +397,7 @@ class MempoolBlocks { | |||||||
|       } |       } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     const isAccelerated : { [txid: string]: boolean } = {}; |     const isAcceleratedBy : { [txid: string]: number[] | false } = {}; | ||||||
| 
 | 
 | ||||||
|     const sizeLimit = (config.MEMPOOL.BLOCK_WEIGHT_UNITS / 4) * 1.2; |     const sizeLimit = (config.MEMPOOL.BLOCK_WEIGHT_UNITS / 4) * 1.2; | ||||||
|     // update this thread's mempool with the results
 |     // update this thread's mempool with the results
 | ||||||
| @ -427,17 +428,19 @@ class MempoolBlocks { | |||||||
|           }; |           }; | ||||||
| 
 | 
 | ||||||
|           const acceleration = accelerations[txid]; |           const acceleration = accelerations[txid]; | ||||||
|           if (isAccelerated[txid] || (acceleration && (!accelerationPool || acceleration.pools.includes(accelerationPool)))) { |           if (isAcceleratedBy[txid] || (acceleration && (!accelerationPool || acceleration.pools.includes(accelerationPool)))) { | ||||||
|             if (!mempoolTx.acceleration) { |             if (!mempoolTx.acceleration) { | ||||||
|               mempoolTx.cpfpDirty = true; |               mempoolTx.cpfpDirty = true; | ||||||
|             } |             } | ||||||
|             mempoolTx.acceleration = true; |             mempoolTx.acceleration = true; | ||||||
|  |             mempoolTx.acceleratedBy = isAcceleratedBy[txid] || acceleration?.pools; | ||||||
|             for (const ancestor of mempoolTx.ancestors || []) { |             for (const ancestor of mempoolTx.ancestors || []) { | ||||||
|               if (!mempool[ancestor.txid].acceleration) { |               if (!mempool[ancestor.txid].acceleration) { | ||||||
|                 mempool[ancestor.txid].cpfpDirty = true; |                 mempool[ancestor.txid].cpfpDirty = true; | ||||||
|               } |               } | ||||||
|               mempool[ancestor.txid].acceleration = true; |               mempool[ancestor.txid].acceleration = true; | ||||||
|               isAccelerated[ancestor.txid] = true; |               mempool[ancestor.txid].acceleratedBy = mempoolTx.acceleratedBy; | ||||||
|  |               isAcceleratedBy[ancestor.txid] = mempoolTx.acceleratedBy; | ||||||
|             } |             } | ||||||
|           } else { |           } else { | ||||||
|             if (mempoolTx.acceleration) { |             if (mempoolTx.acceleration) { | ||||||
|  | |||||||
| @ -820,6 +820,7 @@ class WebsocketHandler { | |||||||
|             position: { |             position: { | ||||||
|               ...mempoolTx.position, |               ...mempoolTx.position, | ||||||
|               accelerated: mempoolTx.acceleration || undefined, |               accelerated: mempoolTx.acceleration || undefined, | ||||||
|  |               acceleratedBy: mempoolTx.acceleratedBy || undefined, | ||||||
|             } |             } | ||||||
|           }; |           }; | ||||||
|           if (!mempoolTx.cpfpChecked && !mempoolTx.acceleration) { |           if (!mempoolTx.cpfpChecked && !mempoolTx.acceleration) { | ||||||
| @ -858,6 +859,7 @@ class WebsocketHandler { | |||||||
|             txInfo.position = { |             txInfo.position = { | ||||||
|               ...mempoolTx.position, |               ...mempoolTx.position, | ||||||
|               accelerated: mempoolTx.acceleration || undefined, |               accelerated: mempoolTx.acceleration || undefined, | ||||||
|  |               acceleratedBy: mempoolTx.acceleratedBy || undefined, | ||||||
|             }; |             }; | ||||||
|             if (!mempoolTx.cpfpChecked) { |             if (!mempoolTx.cpfpChecked) { | ||||||
|               calculateCpfp(mempoolTx, newMempool); |               calculateCpfp(mempoolTx, newMempool); | ||||||
| @ -1134,6 +1136,7 @@ class WebsocketHandler { | |||||||
|               position: { |               position: { | ||||||
|                 ...mempoolTx.position, |                 ...mempoolTx.position, | ||||||
|                 accelerated: mempoolTx.acceleration || undefined, |                 accelerated: mempoolTx.acceleration || undefined, | ||||||
|  |                 acceleratedBy: mempoolTx.acceleratedBy || undefined, | ||||||
|               } |               } | ||||||
|             }); |             }); | ||||||
|           } |           } | ||||||
| @ -1153,6 +1156,7 @@ class WebsocketHandler { | |||||||
|                   ...mempoolTx.position, |                   ...mempoolTx.position, | ||||||
|                 }, |                 }, | ||||||
|                 accelerated: mempoolTx.acceleration || undefined, |                 accelerated: mempoolTx.acceleration || undefined, | ||||||
|  |                 acceleratedBy: mempoolTx.acceleratedBy || undefined, | ||||||
|               }; |               }; | ||||||
|             } |             } | ||||||
|           } |           } | ||||||
|  | |||||||
| @ -111,6 +111,7 @@ export interface TransactionExtended extends IEsploraApi.Transaction { | |||||||
|     vsize: number, |     vsize: number, | ||||||
|   }; |   }; | ||||||
|   acceleration?: boolean; |   acceleration?: boolean; | ||||||
|  |   acceleratedBy?: number[]; | ||||||
|   replacement?: boolean; |   replacement?: boolean; | ||||||
|   uid?: number; |   uid?: number; | ||||||
|   flags?: number; |   flags?: number; | ||||||
| @ -432,7 +433,7 @@ export interface OptimizedStatistic { | |||||||
| 
 | 
 | ||||||
| export interface TxTrackingInfo { | export interface TxTrackingInfo { | ||||||
|   replacedBy?: string, |   replacedBy?: string, | ||||||
|   position?: { block: number, vsize: number, accelerated?: boolean }, |   position?: { block: number, vsize: number, accelerated?: boolean, acceleratedBy?: number[] }, | ||||||
|   cpfp?: { |   cpfp?: { | ||||||
|     ancestors?: Ancestor[], |     ancestors?: Ancestor[], | ||||||
|     bestDescendant?: Ancestor | null, |     bestDescendant?: Ancestor | null, | ||||||
| @ -443,6 +444,7 @@ export interface TxTrackingInfo { | |||||||
|   }, |   }, | ||||||
|   utxoSpent?: { [vout: number]: { vin: number, txid: string } }, |   utxoSpent?: { [vout: number]: { vin: number, txid: string } }, | ||||||
|   accelerated?: boolean, |   accelerated?: boolean, | ||||||
|  |   acceleratedBy?: number[], | ||||||
|   confirmed?: boolean |   confirmed?: boolean | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user