mirror of
https://github.com/benjamin-wilson/public-pool.git
synced 2025-03-27 02:02:10 +01:00
no limit on job history
This commit is contained in:
parent
e1e25172a6
commit
a38c3de5b7
@ -28,10 +28,8 @@ export class BitcoinRpcService {
|
||||
// Maybe use ZeroMQ ?
|
||||
setInterval(async () => {
|
||||
const miningInfo = await this.getMiningInfo();
|
||||
if (miningInfo.blocks > this.blockHeight) {
|
||||
|
||||
if (miningInfo != null && miningInfo.blocks > this.blockHeight) {
|
||||
this._newBlock$.next(miningInfo);
|
||||
|
||||
this.blockHeight = miningInfo.blocks;
|
||||
}
|
||||
|
||||
@ -53,7 +51,12 @@ export class BitcoinRpcService {
|
||||
}
|
||||
|
||||
public async getMiningInfo(): Promise<IMiningInfo> {
|
||||
return await this.client.getmininginfo();
|
||||
try {
|
||||
return await this.client.getmininginfo();
|
||||
} catch (e) {
|
||||
console.log('Error getmininginfo');
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ export class StratumV1JobsService {
|
||||
|
||||
public jobs: MiningJob[] = [];
|
||||
|
||||
public blocks: { id: string, template: IJobTemplate }[] = [];
|
||||
public blocks: { [id: number]: IJobTemplate } = {};
|
||||
|
||||
constructor(
|
||||
private readonly bitcoinRpcService: BitcoinRpcService
|
||||
@ -123,18 +123,10 @@ export class StratumV1JobsService {
|
||||
}),
|
||||
tap((data) => {
|
||||
if (data.blockData.clearJobs) {
|
||||
this.blocks = [];
|
||||
this.blocks = {};
|
||||
this.jobs = [];
|
||||
}
|
||||
|
||||
if (this.blocks.length >= 30) {
|
||||
this.blocks.shift();
|
||||
}
|
||||
|
||||
this.blocks.push({
|
||||
id: data.blockData.id,
|
||||
template: data
|
||||
});
|
||||
this.blocks[data.blockData.id] = data;
|
||||
}),
|
||||
shareReplay({ refCount: true, bufferSize: 1 })
|
||||
)
|
||||
@ -157,8 +149,8 @@ export class StratumV1JobsService {
|
||||
return bytes;
|
||||
}
|
||||
|
||||
public getJobTemplateById(jobTemplateId: string): IJobTemplate {
|
||||
return this.blocks.find(b => b.id === jobTemplateId)?.template;
|
||||
public getJobTemplateById(jobTemplateId: string): IJobTemplate | null {
|
||||
return this.blocks[jobTemplateId];
|
||||
}
|
||||
|
||||
public addJob(job: MiningJob) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user