reset blocks$ and transactions$ observables when network changes
This commit is contained in:
		
							parent
							
								
									2db9c7171a
								
							
						
					
					
						commit
						090da8092a
					
				@ -1,11 +1,11 @@
 | 
			
		||||
import { Inject, Injectable, PLATFORM_ID, LOCALE_ID } from '@angular/core';
 | 
			
		||||
import { ReplaySubject, BehaviorSubject, Subject, fromEvent, Observable, merge } from 'rxjs';
 | 
			
		||||
import { Transaction } from '../interfaces/electrs.interface';
 | 
			
		||||
import { IBackendInfo, MempoolBlock, MempoolBlockWithTransactions, MempoolBlockDelta, MempoolInfo, Recommendedfees, ReplacedTransaction, TransactionStripped } from '../interfaces/websocket.interface';
 | 
			
		||||
import { IBackendInfo, MempoolBlock, MempoolBlockDelta, MempoolInfo, Recommendedfees, ReplacedTransaction, TransactionStripped } from '../interfaces/websocket.interface';
 | 
			
		||||
import { BlockExtended, DifficultyAdjustment, MempoolPosition, OptimizedMempoolStats, RbfTree } from '../interfaces/node-api.interface';
 | 
			
		||||
import { Router, NavigationStart } from '@angular/router';
 | 
			
		||||
import { isPlatformBrowser } from '@angular/common';
 | 
			
		||||
import { map, scan, shareReplay, tap } from 'rxjs/operators';
 | 
			
		||||
import { map, scan, shareReplay } from 'rxjs/operators';
 | 
			
		||||
import { StorageService } from './storage.service';
 | 
			
		||||
 | 
			
		||||
export interface MarkBlockState {
 | 
			
		||||
@ -198,6 +198,11 @@ export class StateService {
 | 
			
		||||
      this.networkChanged$.next(this.env.BASE_MODULE);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    this.networkChanged$.subscribe((network) => {
 | 
			
		||||
      this.transactions$ = new ReplaySubject<TransactionStripped>(6);
 | 
			
		||||
      this.blocks$ = new ReplaySubject<[BlockExtended, string]>(this.env.KEEP_BLOCKS_AMOUNT);
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    this.blockVSize = this.env.BLOCK_WEIGHT_UNITS / 4;
 | 
			
		||||
 | 
			
		||||
    const savedTimePreference = this.storageService.getValue('time-preference-ltr');
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user