2020-02-16 22:15:07 +07:00
|
|
|
import { Injectable } from '@angular/core';
|
|
|
|
import { ReplaySubject, BehaviorSubject, Subject } from 'rxjs';
|
2020-02-23 19:16:50 +07:00
|
|
|
import { Block, Transaction } from '../interfaces/electrs.interface';
|
2020-02-17 20:39:20 +07:00
|
|
|
import { MempoolBlock, MemPoolState } from '../interfaces/websocket.interface';
|
2020-02-17 00:26:57 +07:00
|
|
|
import { OptimizedMempoolStats } from '../interfaces/node-api.interface';
|
2020-02-16 22:15:07 +07:00
|
|
|
|
2020-03-22 17:44:36 +07:00
|
|
|
interface MarkBlockState {
|
|
|
|
blockHeight?: number;
|
|
|
|
mempoolBlockIndex?: number;
|
|
|
|
txFeePerVSize?: number;
|
|
|
|
}
|
|
|
|
|
2020-02-16 22:15:07 +07:00
|
|
|
@Injectable({
|
|
|
|
providedIn: 'root'
|
|
|
|
})
|
|
|
|
export class StateService {
|
|
|
|
latestBlockHeight = 0;
|
|
|
|
blocks$ = new ReplaySubject<Block>(8);
|
|
|
|
conversions$ = new ReplaySubject<any>(1);
|
2020-02-17 20:39:20 +07:00
|
|
|
mempoolStats$ = new ReplaySubject<MemPoolState>();
|
2020-02-16 22:15:07 +07:00
|
|
|
mempoolBlocks$ = new ReplaySubject<MempoolBlock[]>(1);
|
2020-02-23 19:16:50 +07:00
|
|
|
txConfirmed$ = new Subject<Block>();
|
|
|
|
mempoolTransactions$ = new Subject<Transaction>();
|
2020-05-05 15:26:23 +07:00
|
|
|
assetTransactions$ = new Subject<Transaction>();
|
2020-02-23 19:16:50 +07:00
|
|
|
blockTransactions$ = new Subject<Transaction>();
|
|
|
|
|
2020-02-17 00:26:57 +07:00
|
|
|
live2Chart$ = new Subject<OptimizedMempoolStats>();
|
2020-02-16 22:15:07 +07:00
|
|
|
|
|
|
|
viewFiat$ = new BehaviorSubject<boolean>(false);
|
2020-03-09 17:53:54 +07:00
|
|
|
connectionState$ = new BehaviorSubject<0 | 1 | 2>(2);
|
2020-03-22 17:44:36 +07:00
|
|
|
|
|
|
|
markBlock$ = new Subject<MarkBlockState>();
|
2020-02-16 22:15:07 +07:00
|
|
|
}
|