Send mempool effective fee rate changes to frontend & apply
This commit is contained in:
		
							parent
							
								
									3d5c156776
								
							
						
					
					
						commit
						4c569c0ded
					
				| @ -112,6 +112,7 @@ class MempoolBlocks { | |||||||
|     for (let i = 0; i < Math.max(mempoolBlocks.length, prevBlocks.length); i++) { |     for (let i = 0; i < Math.max(mempoolBlocks.length, prevBlocks.length); i++) { | ||||||
|       let added: TransactionStripped[] = []; |       let added: TransactionStripped[] = []; | ||||||
|       let removed: string[] = []; |       let removed: string[] = []; | ||||||
|  |       const changed: { txid: string, rate: number | undefined }[] = []; | ||||||
|       if (mempoolBlocks[i] && !prevBlocks[i]) { |       if (mempoolBlocks[i] && !prevBlocks[i]) { | ||||||
|         added = mempoolBlocks[i].transactions; |         added = mempoolBlocks[i].transactions; | ||||||
|       } else if (!mempoolBlocks[i] && prevBlocks[i]) { |       } else if (!mempoolBlocks[i] && prevBlocks[i]) { | ||||||
| @ -120,7 +121,7 @@ class MempoolBlocks { | |||||||
|         const prevIds = {}; |         const prevIds = {}; | ||||||
|         const newIds = {}; |         const newIds = {}; | ||||||
|         prevBlocks[i].transactions.forEach(tx => { |         prevBlocks[i].transactions.forEach(tx => { | ||||||
|           prevIds[tx.txid] = true; |           prevIds[tx.txid] = tx; | ||||||
|         }); |         }); | ||||||
|         mempoolBlocks[i].transactions.forEach(tx => { |         mempoolBlocks[i].transactions.forEach(tx => { | ||||||
|           newIds[tx.txid] = true; |           newIds[tx.txid] = true; | ||||||
| @ -133,12 +134,15 @@ class MempoolBlocks { | |||||||
|         mempoolBlocks[i].transactions.forEach(tx => { |         mempoolBlocks[i].transactions.forEach(tx => { | ||||||
|           if (!prevIds[tx.txid]) { |           if (!prevIds[tx.txid]) { | ||||||
|             added.push(tx); |             added.push(tx); | ||||||
|  |           } else if (tx.rate !== prevIds[tx.txid].rate) { | ||||||
|  |             changed.push({ txid: tx.txid, rate: tx.rate }); | ||||||
|           } |           } | ||||||
|         }); |         }); | ||||||
|       } |       } | ||||||
|       mempoolBlockDeltas.push({ |       mempoolBlockDeltas.push({ | ||||||
|         added, |         added, | ||||||
|         removed |         removed, | ||||||
|  |         changed, | ||||||
|       }); |       }); | ||||||
|     } |     } | ||||||
|     return mempoolBlockDeltas; |     return mempoolBlockDeltas; | ||||||
|  | |||||||
| @ -58,6 +58,7 @@ export interface MempoolBlockWithTransactions extends MempoolBlock { | |||||||
| export interface MempoolBlockDelta { | export interface MempoolBlockDelta { | ||||||
|   added: TransactionStripped[]; |   added: TransactionStripped[]; | ||||||
|   removed: string[]; |   removed: string[]; | ||||||
|  |   changed: { txid: string, rate: number | undefined }[]; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| interface VinStrippedToScriptsig { | interface VinStrippedToScriptsig { | ||||||
|  | |||||||
| @ -132,9 +132,9 @@ export class BlockOverviewGraphComponent implements AfterViewInit, OnDestroy, On | |||||||
|     } |     } | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   update(add: TransactionStripped[], remove: string[], direction: string = 'left', resetLayout: boolean = false): void { |   update(add: TransactionStripped[], remove: string[], change: { txid: string, rate: number | undefined }[], direction: string = 'left', resetLayout: boolean = false): void { | ||||||
|     if (this.scene) { |     if (this.scene) { | ||||||
|       this.scene.update(add, remove, direction, resetLayout); |       this.scene.update(add, remove, change, direction, resetLayout); | ||||||
|       this.start(); |       this.start(); | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  | |||||||
| @ -150,7 +150,7 @@ export default class BlockScene { | |||||||
|     this.updateAll(startTime, 200, direction); |     this.updateAll(startTime, 200, direction); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   update(add: TransactionStripped[], remove: string[], direction: string = 'left', resetLayout: boolean = false): void { |   update(add: TransactionStripped[], remove: string[], change: { txid: string, rate: number | undefined }[], direction: string = 'left', resetLayout: boolean = false): void { | ||||||
|     const startTime = performance.now(); |     const startTime = performance.now(); | ||||||
|     const removed = this.removeBatch(remove, startTime, direction); |     const removed = this.removeBatch(remove, startTime, direction); | ||||||
| 
 | 
 | ||||||
| @ -172,6 +172,15 @@ export default class BlockScene { | |||||||
|         this.place(tx); |         this.place(tx); | ||||||
|       }); |       }); | ||||||
|     } else { |     } else { | ||||||
|  |       // update effective rates
 | ||||||
|  |       change.forEach(tx => { | ||||||
|  |         if (this.txs[tx.txid]) { | ||||||
|  |           this.txs[tx.txid].feerate = tx.rate || (this.txs[tx.txid].fee / this.txs[tx.txid].vsize); | ||||||
|  |           this.txs[tx.txid].rate = tx.rate; | ||||||
|  |           this.txs[tx.txid].dirty = true; | ||||||
|  |         } | ||||||
|  |       }); | ||||||
|  | 
 | ||||||
|       // try to insert new txs directly
 |       // try to insert new txs directly
 | ||||||
|       const remaining = []; |       const remaining = []; | ||||||
|       add.map(tx => new TxView(tx, this)).sort(feeRateDescending).forEach(tx => { |       add.map(tx => new TxView(tx, this)).sort(feeRateDescending).forEach(tx => { | ||||||
|  | |||||||
| @ -99,7 +99,7 @@ export class MempoolBlockOverviewComponent implements OnInit, OnDestroy, OnChang | |||||||
|       const direction = (this.blockIndex == null || this.index < this.blockIndex) ? this.poolDirection : this.chainDirection; |       const direction = (this.blockIndex == null || this.index < this.blockIndex) ? this.poolDirection : this.chainDirection; | ||||||
|       this.blockGraph.replace(delta.added, direction); |       this.blockGraph.replace(delta.added, direction); | ||||||
|     } else { |     } else { | ||||||
|       this.blockGraph.update(delta.added, delta.removed, blockMined ? this.chainDirection : this.poolDirection, blockMined); |       this.blockGraph.update(delta.added, delta.removed, delta.changed || [], blockMined ? this.chainDirection : this.poolDirection, blockMined); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     this.lastBlockHeight = this.stateService.latestBlockHeight; |     this.lastBlockHeight = this.stateService.latestBlockHeight; | ||||||
|  | |||||||
| @ -54,6 +54,7 @@ export interface MempoolBlockWithTransactions extends MempoolBlock { | |||||||
| export interface MempoolBlockDelta { | export interface MempoolBlockDelta { | ||||||
|   added: TransactionStripped[], |   added: TransactionStripped[], | ||||||
|   removed: string[], |   removed: string[], | ||||||
|  |   changed?: { txid: string, rate: number | undefined }[]; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export interface MempoolInfo { | export interface MempoolInfo { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user