Update hashrate estimate when new blocks arrive
This commit is contained in:
		
							parent
							
								
									2907054a01
								
							
						
					
					
						commit
						c3c0696844
					
				| @ -1,7 +1,7 @@ | |||||||
| import { ChangeDetectionStrategy, Component, Inject, Input, LOCALE_ID, OnInit, HostBinding } from '@angular/core'; | import { ChangeDetectionStrategy, Component, Inject, Input, LOCALE_ID, OnInit, HostBinding } from '@angular/core'; | ||||||
| import { EChartsOption, graphic } from 'echarts'; | import { EChartsOption, graphic } from 'echarts'; | ||||||
| import { Observable } from 'rxjs'; | import { merge, Observable, of } from 'rxjs'; | ||||||
| import { map, share, startWith, switchMap, tap } from 'rxjs/operators'; | import { map, mergeMap, share, startWith, switchMap, tap } from 'rxjs/operators'; | ||||||
| import { ApiService } from '../../services/api.service'; | import { ApiService } from '../../services/api.service'; | ||||||
| import { SeoService } from '../../services/seo.service'; | import { SeoService } from '../../services/seo.service'; | ||||||
| import { formatNumber } from '@angular/common'; | import { formatNumber } from '@angular/common'; | ||||||
| @ -84,7 +84,8 @@ export class HashrateChartComponent implements OnInit { | |||||||
|         } |         } | ||||||
|       }); |       }); | ||||||
| 
 | 
 | ||||||
|     this.hashrateObservable$ = this.radioGroupForm.get('dateSpan').valueChanges |     this.hashrateObservable$ = merge( | ||||||
|  |       this.radioGroupForm.get('dateSpan').valueChanges | ||||||
|         .pipe( |         .pipe( | ||||||
|           startWith(this.radioGroupForm.controls.dateSpan.value), |           startWith(this.radioGroupForm.controls.dateSpan.value), | ||||||
|           switchMap((timespan) => { |           switchMap((timespan) => { | ||||||
| @ -95,9 +96,17 @@ export class HashrateChartComponent implements OnInit { | |||||||
|             firstRun = false; |             firstRun = false; | ||||||
|             this.miningWindowPreference = timespan; |             this.miningWindowPreference = timespan; | ||||||
|             this.isLoading = true; |             this.isLoading = true; | ||||||
|           return this.apiService.getHistoricalHashrate$(timespan) |             return this.apiService.getHistoricalHashrate$(this.timespan); | ||||||
|  |           }) | ||||||
|  |         ), | ||||||
|  |         this.stateService.chainTip$ | ||||||
|           .pipe( |           .pipe( | ||||||
|               tap((response) => { |             switchMap(() => { | ||||||
|  |               return this.apiService.getHistoricalHashrate$(this.timespan); | ||||||
|  |             }) | ||||||
|  |           ) | ||||||
|  |       ).pipe( | ||||||
|  |         tap((response: any) => { | ||||||
|           const data = response.body; |           const data = response.body; | ||||||
| 
 | 
 | ||||||
|           // We generate duplicated data point so the tooltip works nicely
 |           // We generate duplicated data point so the tooltip works nicely
 | ||||||
| @ -154,8 +163,6 @@ export class HashrateChartComponent implements OnInit { | |||||||
|             currentHashrate: data.currentHashrate, |             currentHashrate: data.currentHashrate, | ||||||
|           }; |           }; | ||||||
|         }), |         }), | ||||||
|             ); |  | ||||||
|         }), |  | ||||||
|         share() |         share() | ||||||
|       ); |       ); | ||||||
|   } |   } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user