mirror of
https://github.com/benjamin-wilson/public-pool.git
synced 2026-09-29 09:05:06 -07:00
optimizations and cleanup
This commit is contained in:
@@ -2,7 +2,7 @@ import { Injectable } from '@nestjs/common';
|
||||
import * as bitcoinjs from 'bitcoinjs-lib';
|
||||
import * as merkle from 'merkle-lib';
|
||||
import * as merkleProof from 'merkle-lib/proof';
|
||||
import { combineLatest, filter, from, interval, map, Observable, shareReplay, startWith, switchMap, tap } from 'rxjs';
|
||||
import { combineLatest, delay, filter, from, interval, map, Observable, shareReplay, startWith, switchMap, tap } from 'rxjs';
|
||||
|
||||
import { MiningJob } from '../models/MiningJob';
|
||||
import { BitcoinRpcService } from './bitcoin-rpc.service';
|
||||
@@ -35,11 +35,16 @@ export class StratumV1JobsService {
|
||||
|
||||
public blocks: { [id: number]: IJobTemplate } = {};
|
||||
|
||||
// offset the interval so that all the cluster processes don't try and refresh at the same time.
|
||||
private delay = process.env.NODE_APP_INSTANCE == null ? 0 : parseInt(process.env.NODE_APP_INSTANCE) * 5000;
|
||||
|
||||
constructor(
|
||||
private readonly bitcoinRpcService: BitcoinRpcService
|
||||
) {
|
||||
|
||||
this.newMiningJob$ = combineLatest([this.bitcoinRpcService.newBlock$, interval(60000).pipe(startWith(-1))]).pipe(
|
||||
console.log(this.delay)
|
||||
|
||||
this.newMiningJob$ = combineLatest([this.bitcoinRpcService.newBlock$, interval(60000).pipe(delay(this.delay), startWith(-1))]).pipe(
|
||||
switchMap(([miningInfo, interval]) => {
|
||||
return from(this.bitcoinRpcService.getBlockTemplate()).pipe(map((blockTemplate) => {
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user