Cache pool accounting summary

This commit is contained in:
Ben
2026-06-07 23:02:57 -04:00
parent eac0fe65ab
commit 93dde1a899
2 changed files with 44 additions and 1 deletions
+21 -1
View File
@@ -3,15 +3,18 @@ import { Injectable, OnModuleInit } from '@nestjs/common';
import { UserAgentReportService } from '../ORM/_views/user-agent-report/user-agent-report.service';
import { ClientService } from '../ORM/client/client.service';
import { RpcBlockService } from '../ORM/rpc-block/rpc-block.service';
import { ShareAccountingService } from '../ORM/share-accounting/share-accounting.service';
@Injectable()
export class AppService implements OnModuleInit {
private refreshingLiveUserAgentReport = false;
private refreshingPoolSummary = false;
constructor(
private readonly clientService: ClientService,
private readonly rpcBlockService: RpcBlockService,
private readonly userAgentReportService: UserAgentReportService
private readonly userAgentReportService: UserAgentReportService,
private readonly shareAccountingService: ShareAccountingService
) {
}
@@ -30,10 +33,12 @@ export class AppService implements OnModuleInit {
setInterval(async () => {
await this.refreshLiveUserAgentReport();
await this.refreshPoolSummary();
}, 1000 * 30);
setTimeout(async () => {
await this.refreshLiveUserAgentReport();
await this.refreshPoolSummary();
}, 1000 * 15);
setInterval(async () => {
@@ -67,4 +72,19 @@ export class AppService implements OnModuleInit {
this.refreshingLiveUserAgentReport = false;
}
}
private async refreshPoolSummary() {
if (this.refreshingPoolSummary) {
return;
}
this.refreshingPoolSummary = true;
try {
await this.shareAccountingService.refreshPoolSummary();
} catch (error) {
console.error(`Failed refreshing pool accounting summary: ${error.message}`);
} finally {
this.refreshingPoolSummary = false;
}
}
}