network stats and better client hashrate estimation

This commit is contained in:
Ben Wilson
2023-08-03 22:37:48 -04:00
parent 3c4c35ab53
commit f907d6efe1
4 changed files with 31 additions and 19 deletions
+2 -2
View File
@@ -1,7 +1,7 @@
import { Injectable } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { RPCClient } from 'rpc-bitcoin';
import { BehaviorSubject, filter } from 'rxjs';
import { BehaviorSubject, filter, shareReplay } from 'rxjs';
import { IBlockTemplate } from '../models/bitcoin-rpc/IBlockTemplate';
import { IMiningInfo } from '../models/bitcoin-rpc/IMiningInfo';
@@ -12,7 +12,7 @@ export class BitcoinRpcService {
private blockHeight = 0;
private client: RPCClient;
private _newBlock$: BehaviorSubject<IMiningInfo> = new BehaviorSubject(undefined);
public newBlock$ = this._newBlock$.pipe(filter(block => block != null));
public newBlock$ = this._newBlock$.pipe(filter(block => block != null), shareReplay({ refCount: true, bufferSize: 1 }));
constructor(private readonly configService: ConfigService) {
const url = this.configService.get('BITCOIN_RPC_URL');