Separate mining and audit subscriptions
This commit is contained in:
		
							parent
							
								
									cee1b39640
								
							
						
					
					
						commit
						bbaa5dafb9
					
				| @ -81,6 +81,7 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy { | |||||||
|   mempoolBlocksSubscription: Subscription; |   mempoolBlocksSubscription: Subscription; | ||||||
|   blocksSubscription: Subscription; |   blocksSubscription: Subscription; | ||||||
|   miningSubscription: Subscription; |   miningSubscription: Subscription; | ||||||
|  |   auditSubscription: Subscription; | ||||||
|   currencyChangeSubscription: Subscription; |   currencyChangeSubscription: Subscription; | ||||||
|   fragmentParams: URLSearchParams; |   fragmentParams: URLSearchParams; | ||||||
|   rbfTransaction: undefined | Transaction; |   rbfTransaction: undefined | Transaction; | ||||||
| @ -308,24 +309,32 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy { | |||||||
|       filter((target) => target.txid === this.txId), |       filter((target) => target.txid === this.txId), | ||||||
|       tap(() => { |       tap(() => { | ||||||
|         this.pool = null; |         this.pool = null; | ||||||
|  |       }), | ||||||
|  |       switchMap(({ hash, height }) => { | ||||||
|  |         const foundBlock = this.cacheService.getCachedBlock(height) || null; | ||||||
|  |         return foundBlock ? of(foundBlock.extras.pool) : this.apiService.getBlock$(hash).pipe( | ||||||
|  |           map(block => block.extras.pool), | ||||||
|  |           retry({ count: 3, delay: 2000 }), | ||||||
|  |           catchError(() => of(null)) | ||||||
|  |         ); | ||||||
|  |       }), | ||||||
|  |       catchError((e) => { | ||||||
|  |         return of(null); | ||||||
|  |       }) | ||||||
|  |     ).subscribe(pool => { | ||||||
|  |       this.pool = pool; | ||||||
|  |     }); | ||||||
|  | 
 | ||||||
|  |     this.auditSubscription = this.fetchMiningInfo$.pipe( | ||||||
|  |       filter((target) => target.txid === this.txId), | ||||||
|  |       tap(() => { | ||||||
|         this.auditStatus = null; |         this.auditStatus = null; | ||||||
|       }), |       }), | ||||||
|       switchMap(({ hash, height, txid }) => { |       switchMap(({ hash, height, txid }) => { | ||||||
|         const foundBlock = this.cacheService.getCachedBlock(height) || null; |  | ||||||
|         const auditAvailable = this.isAuditAvailable(height); |         const auditAvailable = this.isAuditAvailable(height); | ||||||
|         const isCoinbase = this.tx.vin.some(v => v.is_coinbase); |         const isCoinbase = this.tx.vin.some(v => v.is_coinbase); | ||||||
|         const fetchAudit = auditAvailable && !isCoinbase; |         const fetchAudit = auditAvailable && !isCoinbase; | ||||||
|         return combineLatest([ |         return fetchAudit ? this.apiService.getBlockAudit$(hash).pipe( | ||||||
|           foundBlock ? of(foundBlock.extras.pool) : this.apiService.getBlock$(hash).pipe( |  | ||||||
|             map(block => { |  | ||||||
|               return block.extras.pool; |  | ||||||
|             }), |  | ||||||
|             retry({ count: 3, delay: 2000 }), |  | ||||||
|             catchError(() => { |  | ||||||
|               return of(null); |  | ||||||
|             }) |  | ||||||
|           ), |  | ||||||
|           fetchAudit ? this.apiService.getBlockAudit$(hash).pipe( |  | ||||||
|           map(audit => { |           map(audit => { | ||||||
|             const isAdded = audit.addedTxs.includes(txid); |             const isAdded = audit.addedTxs.includes(txid); | ||||||
|             const isPrioritized = audit.prioritizedTxs.includes(txid); |             const isPrioritized = audit.prioritizedTxs.includes(txid); | ||||||
| @ -345,14 +354,12 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy { | |||||||
|           catchError(() => { |           catchError(() => { | ||||||
|             return of(null); |             return of(null); | ||||||
|           }) |           }) | ||||||
|           ) : of(isCoinbase ? { coinbase: true } : null) |         ) : of(isCoinbase ? { coinbase: true } : null); | ||||||
|         ]); |  | ||||||
|       }), |       }), | ||||||
|       catchError((e) => { |       catchError((e) => { | ||||||
|         return of(null); |         return of(null); | ||||||
|       }) |       }) | ||||||
|     ).subscribe(([pool, auditStatus]) => { |     ).subscribe(auditStatus => { | ||||||
|       this.pool = pool; |  | ||||||
|       this.auditStatus = auditStatus; |       this.auditStatus = auditStatus; | ||||||
| 
 | 
 | ||||||
|       this.setIsAccelerated(); |       this.setIsAccelerated(); | ||||||
| @ -858,6 +865,7 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy { | |||||||
|     this.mempoolBlocksSubscription.unsubscribe(); |     this.mempoolBlocksSubscription.unsubscribe(); | ||||||
|     this.blocksSubscription.unsubscribe(); |     this.blocksSubscription.unsubscribe(); | ||||||
|     this.miningSubscription?.unsubscribe(); |     this.miningSubscription?.unsubscribe(); | ||||||
|  |     this.auditSubscription?.unsubscribe(); | ||||||
|     this.currencyChangeSubscription?.unsubscribe(); |     this.currencyChangeSubscription?.unsubscribe(); | ||||||
|     this.leaveTransaction(); |     this.leaveTransaction(); | ||||||
|   } |   } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user