mirror of
https://github.com/benjamin-wilson/public-pool.git
synced 2026-09-29 09:05:06 -07:00
api
This commit is contained in:
@@ -18,12 +18,13 @@ export class AppController {
|
|||||||
getClientInfo(@Param('clientId') clientId: string) {
|
getClientInfo(@Param('clientId') clientId: string) {
|
||||||
const workers = this.stratumV1Service.clients.filter(client => client.clientAuthorization.address === clientId);
|
const workers = this.stratumV1Service.clients.filter(client => client.clientAuthorization.address === clientId);
|
||||||
return {
|
return {
|
||||||
workers: workers.length,
|
workersCount: workers.length,
|
||||||
workerIds: workers.map(worker => {
|
workers: workers.map(worker => {
|
||||||
return {
|
return {
|
||||||
id: worker.id,
|
id: worker.id,
|
||||||
bestDifficulty: worker.statistics.bestDifficulty,
|
name: worker.clientAuthorization.worker,
|
||||||
hashrate: worker.statistics.getHashrate()
|
bestDifficulty: Math.floor(worker.statistics.bestDifficulty),
|
||||||
|
hashRate: Math.floor(worker.statistics.getHashRate()),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -33,7 +34,10 @@ export class AppController {
|
|||||||
getWorkerInfo(@Param('clientId') clientId: string, @Param('workerId') workerId: string) {
|
getWorkerInfo(@Param('clientId') clientId: string, @Param('workerId') workerId: string) {
|
||||||
const worker = this.stratumV1Service.clients.find(client => client.clientAuthorization.address === clientId && client.id === workerId);
|
const worker = this.stratumV1Service.clients.find(client => client.clientAuthorization.address === clientId && client.id === workerId);
|
||||||
return {
|
return {
|
||||||
id: worker.id
|
id: worker.id,
|
||||||
|
name: worker.clientAuthorization.worker,
|
||||||
|
bestDifficulty: Math.floor(worker.statistics.bestDifficulty),
|
||||||
|
hashData: worker.statistics.historicSubmissions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-3
@@ -4,8 +4,8 @@ import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify
|
|||||||
|
|
||||||
import { AppModule } from './app.module';
|
import { AppModule } from './app.module';
|
||||||
|
|
||||||
|
|
||||||
async function bootstrap() {
|
async function bootstrap() {
|
||||||
|
|
||||||
const app = await NestFactory.create<NestFastifyApplication>(AppModule, new FastifyAdapter());
|
const app = await NestFactory.create<NestFastifyApplication>(AppModule, new FastifyAdapter());
|
||||||
app.setGlobalPrefix('api')
|
app.setGlobalPrefix('api')
|
||||||
app.useGlobalPipes(
|
app.useGlobalPipes(
|
||||||
@@ -18,7 +18,9 @@ async function bootstrap() {
|
|||||||
);
|
);
|
||||||
app.enableCors();
|
app.enableCors();
|
||||||
|
|
||||||
await app.listen(process.env.PORT, '0.0.0.0');
|
await app.listen(process.env.PORT, '0.0.0.0', () => {
|
||||||
console.log(`http listening on port ${process.env.PORT}`)
|
console.log(`https listening on port ${process.env.PORT}`);
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
bootstrap();
|
bootstrap();
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export class StratumV1ClientStatistics {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public getHashrate() {
|
public getHashRate() {
|
||||||
return this.historicSubmissions.reduce((pre, cur, idx, arr) => {
|
return this.historicSubmissions.reduce((pre, cur, idx, arr) => {
|
||||||
if (idx === 0) {
|
if (idx === 0) {
|
||||||
pre.time = cur.time;
|
pre.time = cur.time;
|
||||||
|
|||||||
Reference in New Issue
Block a user