2019-07-21 17:59:47 +03:00
|
|
|
import { Injectable } from '@angular/core';
|
2019-07-26 12:48:32 +03:00
|
|
|
import { ReplaySubject, BehaviorSubject, Subject } from 'rxjs';
|
|
|
|
import { IMempoolInfo, IBlock, IProjectedBlock, ITransaction, IMempoolStats } from '../blockchain/interfaces';
|
2019-07-21 17:59:47 +03:00
|
|
|
|
2019-07-24 23:08:28 +03:00
|
|
|
export interface IMemPoolState {
|
2019-07-21 17:59:47 +03:00
|
|
|
memPoolInfo: IMempoolInfo;
|
|
|
|
txPerSecond: number;
|
|
|
|
vBytesPerSecond: number;
|
|
|
|
}
|
|
|
|
|
2019-07-24 23:08:28 +03:00
|
|
|
export interface ITxTracking {
|
|
|
|
enabled: boolean;
|
|
|
|
tx: ITransaction | null;
|
|
|
|
blockHeight: number;
|
|
|
|
notFound: boolean;
|
|
|
|
}
|
|
|
|
|
2019-07-21 17:59:47 +03:00
|
|
|
@Injectable({
|
|
|
|
providedIn: 'root'
|
|
|
|
})
|
|
|
|
export class MemPoolService {
|
2019-07-24 23:08:28 +03:00
|
|
|
mempoolStats$ = new ReplaySubject<IMemPoolState>();
|
|
|
|
isOffline$ = new ReplaySubject<boolean>();
|
|
|
|
txIdSearch$ = new ReplaySubject<string>();
|
|
|
|
conversions$ = new ReplaySubject<any>();
|
|
|
|
mempoolWeight$ = new ReplaySubject<number>();
|
2019-07-26 12:48:32 +03:00
|
|
|
live2Chart$ = new Subject<IMempoolStats>();
|
2019-07-24 23:08:28 +03:00
|
|
|
txTracking$ = new BehaviorSubject<ITxTracking>({
|
|
|
|
enabled: false,
|
|
|
|
tx: null,
|
|
|
|
blockHeight: 0,
|
|
|
|
notFound: false,
|
|
|
|
});
|
|
|
|
blocks$ = new ReplaySubject<IBlock>(8);
|
|
|
|
projectedBlocks$ = new BehaviorSubject<IProjectedBlock[]>([]);
|
2019-07-21 17:59:47 +03:00
|
|
|
}
|