mirror of
https://github.com/benjamin-wilson/public-pool.git
synced 2025-03-17 13:21:43 +01:00
reduce heartbeat updates
This commit is contained in:
parent
982194b4e9
commit
1d6670051f
@ -45,8 +45,8 @@ export class ClientService {
|
||||
.execute();
|
||||
}
|
||||
|
||||
public async heartbeat(address: string, clientName: string, sessionId: string, hashRate: number) {
|
||||
return await this.clientRepository.update({ address, clientName, sessionId }, { hashRate, deletedAt: null, updatedAt: new Date() });
|
||||
public async heartbeat(address: string, clientName: string, sessionId: string, hashRate: number, updatedAt: Date) {
|
||||
return await this.clientRepository.update({ address, clientName, sessionId }, { hashRate, deletedAt: null, updatedAt });
|
||||
}
|
||||
|
||||
// public async save(client: Partial<ClientEntity>) {
|
||||
|
@ -516,7 +516,13 @@ export class StratumV1Client {
|
||||
}
|
||||
try {
|
||||
await this.statistics.addShares(this.sessionDifficulty);
|
||||
await this.clientService.heartbeat(this.entity.address, this.entity.clientName, this.entity.sessionId, this.hashRate);
|
||||
const now = new Date();
|
||||
// only update every minute
|
||||
if (now.getTime() - this.entity.updatedAt.getTime() > 1000 * 60) {
|
||||
await this.clientService.heartbeat(this.entity.address, this.entity.clientName, this.entity.sessionId, this.hashRate, now);
|
||||
this.entity.updatedAt = now;
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
const err = new StratumErrorMessage(
|
||||
|
Loading…
x
Reference in New Issue
Block a user