mirror of
https://github.com/benjamin-wilson/public-pool.git
synced 2026-09-29 17:15:03 -07:00
Avoid raw pool summary on API process
This commit is contained in:
@@ -140,19 +140,42 @@ export class ShareAccountingService implements OnModuleDestroy {
|
|||||||
return cached;
|
return cached;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (process.env.API_ONLY === 'true') {
|
||||||
|
return this.emptySummary();
|
||||||
|
}
|
||||||
|
|
||||||
return this.getSummary({});
|
return this.getSummary({});
|
||||||
}
|
}
|
||||||
|
|
||||||
public async refreshPoolSummary(): Promise<ShareAccountingSummary> {
|
public async refreshPoolSummary(): Promise<ShareAccountingSummary> {
|
||||||
const summary = await this.getSummary({});
|
const summary = await this.getSummary({});
|
||||||
await this.redisMessagingService
|
await this.redisMessagingService
|
||||||
?.setJsonCache(this.poolSummaryCacheKey, summary, 60 * 1000)
|
?.setJsonCache(this.poolSummaryCacheKey, summary, 10 * 60 * 1000)
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error(`Pool accounting summary cache write failed: ${error.message}`);
|
console.error(`Pool accounting summary cache write failed: ${error.message}`);
|
||||||
});
|
});
|
||||||
return summary;
|
return summary;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private emptySummary(): ShareAccountingSummary {
|
||||||
|
return {
|
||||||
|
totalAcceptedShares: 0,
|
||||||
|
totalCreditedDifficulty: 0,
|
||||||
|
acceptedSharesLast10Minutes: 0,
|
||||||
|
creditedDifficultyLast10Minutes: 0,
|
||||||
|
acceptedSharesLastHour: 0,
|
||||||
|
creditedDifficultyLastHour: 0,
|
||||||
|
acceptedSharesLastDay: 0,
|
||||||
|
creditedDifficultyLastDay: 0,
|
||||||
|
hashRateLast10Minutes: 0,
|
||||||
|
hashRateLastHour: 0,
|
||||||
|
bestSubmissionDifficulty: 0,
|
||||||
|
blockCandidateCount: 0,
|
||||||
|
latestShareAt: null,
|
||||||
|
protocolBreakdown: [],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
public async getAddressSummary(address: string): Promise<ShareAccountingSummary> {
|
public async getAddressSummary(address: string): Promise<ShareAccountingSummary> {
|
||||||
return this.getSummary({ address });
|
return this.getSummary({ address });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ export class AppService implements OnModuleInit {
|
|||||||
|
|
||||||
setInterval(async () => {
|
setInterval(async () => {
|
||||||
await this.refreshLiveUserAgentReport();
|
await this.refreshLiveUserAgentReport();
|
||||||
await this.refreshPoolSummary();
|
|
||||||
}, 1000 * 30);
|
}, 1000 * 30);
|
||||||
|
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
@@ -41,6 +40,10 @@ export class AppService implements OnModuleInit {
|
|||||||
await this.refreshPoolSummary();
|
await this.refreshPoolSummary();
|
||||||
}, 1000 * 15);
|
}, 1000 * 15);
|
||||||
|
|
||||||
|
setInterval(async () => {
|
||||||
|
await this.refreshPoolSummary();
|
||||||
|
}, 1000 * 60 * 5);
|
||||||
|
|
||||||
setInterval(async () => {
|
setInterval(async () => {
|
||||||
console.log('Refreshing user agent report view')
|
console.log('Refreshing user agent report view')
|
||||||
await this.userAgentReportService.refreshReport();
|
await this.userAgentReportService.refreshReport();
|
||||||
|
|||||||
Reference in New Issue
Block a user