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