mirror of
https://github.com/benjamin-wilson/public-pool.git
synced 2026-09-29 17:15:03 -07:00
removed hash from client stats table, connection pool size
This commit is contained in:
@@ -1,15 +1,14 @@
|
|||||||
import { Column, Entity, Index, PrimaryColumn } from 'typeorm';
|
import { Column, Entity, Index, PrimaryGeneratedColumn } from 'typeorm';
|
||||||
|
|
||||||
import { TrackedEntity } from '../utils/TrackedEntity.entity';
|
import { TrackedEntity } from '../utils/TrackedEntity.entity';
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
//Index for the heartbeat update
|
//Index for getHashRateForSession
|
||||||
@Index(["address", "clientName", "sessionId", "time"])
|
@Index(["address", "clientName", "sessionId"])
|
||||||
export class ClientStatisticsEntity extends TrackedEntity {
|
export class ClientStatisticsEntity extends TrackedEntity {
|
||||||
|
|
||||||
@PrimaryColumn({ length: 64, type: 'varchar' })
|
@PrimaryGeneratedColumn()
|
||||||
submissionHash: string;
|
id: number;
|
||||||
|
|
||||||
|
|
||||||
@Column({ length: 62, type: 'varchar' })
|
@Column({ length: 62, type: 'varchar' })
|
||||||
address: string;
|
address: string;
|
||||||
|
|||||||
+1
-1
@@ -64,7 +64,7 @@ const ORMModules = [
|
|||||||
],
|
],
|
||||||
synchronize: configService.get('PRODUCTION') != 'true',
|
synchronize: configService.get('PRODUCTION') != 'true',
|
||||||
logging: false,
|
logging: false,
|
||||||
|
poolSize: 30
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
imports: [ConfigModule],
|
imports: [ConfigModule],
|
||||||
|
|||||||
@@ -505,7 +505,7 @@ export class StratumV1Client {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await this.statistics.addSubmission(this.entity, submissionHash, this.sessionDifficulty);
|
await this.statistics.addSubmission(this.entity, this.sessionDifficulty);
|
||||||
await this.clientService.heartbeat(this.entity.address, this.entity.clientName, this.entity.sessionId, this.hashRate);
|
await this.clientService.heartbeat(this.entity.address, this.entity.clientName, this.entity.sessionId, this.hashRate);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ export class StratumV1ClientStatistics {
|
|||||||
this.submissionCacheStart = new Date();
|
this.submissionCacheStart = new Date();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async addSubmission(client: ClientEntity, submissionHash: string, targetDifficulty: number) {
|
public async addSubmission(client: ClientEntity, targetDifficulty: number) {
|
||||||
|
|
||||||
if (this.submissionCache.length > CACHE_SIZE) {
|
if (this.submissionCache.length > CACHE_SIZE) {
|
||||||
this.submissionCache.shift();
|
this.submissionCache.shift();
|
||||||
@@ -31,15 +31,14 @@ export class StratumV1ClientStatistics {
|
|||||||
// 10 min
|
// 10 min
|
||||||
var coeff = 1000 * 60 * 10;
|
var coeff = 1000 * 60 * 10;
|
||||||
var date = new Date();
|
var date = new Date();
|
||||||
var rounded = new Date(Math.round(date.getTime() / coeff) * coeff);
|
var rounded = new Date(Math.floor(date.getTime() / coeff) * coeff);
|
||||||
|
|
||||||
await this.clientStatisticsService.save({
|
await this.clientStatisticsService.save({
|
||||||
time: rounded.getTime(),
|
time: rounded.getTime(),
|
||||||
shares: targetDifficulty,
|
shares: targetDifficulty,
|
||||||
address: client.address,
|
address: client.address,
|
||||||
clientName: client.clientName,
|
clientName: client.clientName,
|
||||||
sessionId: client.sessionId,
|
sessionId: client.sessionId
|
||||||
submissionHash
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user