mirror of
https://github.com/benjamin-wilson/public-pool.git
synced 2026-09-29 09:05:06 -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;
|
||||
}
|
||||
|
||||
if (process.env.API_ONLY === 'true') {
|
||||
return this.emptySummary();
|
||||
}
|
||||
|
||||
return this.getSummary({});
|
||||
}
|
||||
|
||||
public async refreshPoolSummary(): Promise<ShareAccountingSummary> {
|
||||
const summary = await this.getSummary({});
|
||||
await this.redisMessagingService
|
||||
?.setJsonCache(this.poolSummaryCacheKey, summary, 60 * 1000)
|
||||
?.setJsonCache(this.poolSummaryCacheKey, summary, 10 * 60 * 1000)
|
||||
.catch(error => {
|
||||
console.error(`Pool accounting summary cache write failed: ${error.message}`);
|
||||
});
|
||||
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> {
|
||||
return this.getSummary({ address });
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@ export class AppService implements OnModuleInit {
|
||||
|
||||
setInterval(async () => {
|
||||
await this.refreshLiveUserAgentReport();
|
||||
await this.refreshPoolSummary();
|
||||
}, 1000 * 30);
|
||||
|
||||
setTimeout(async () => {
|
||||
@@ -41,6 +40,10 @@ export class AppService implements OnModuleInit {
|
||||
await this.refreshPoolSummary();
|
||||
}, 1000 * 15);
|
||||
|
||||
setInterval(async () => {
|
||||
await this.refreshPoolSummary();
|
||||
}, 1000 * 60 * 5);
|
||||
|
||||
setInterval(async () => {
|
||||
console.log('Refreshing user agent report view')
|
||||
await this.userAgentReportService.refreshReport();
|
||||
|
||||
Reference in New Issue
Block a user