mirror of
https://github.com/benjamin-wilson/public-pool.git
synced 2026-09-29 09:05:06 -07:00
cors, bug
This commit is contained in:
+31
-4
@@ -1,12 +1,39 @@
|
||||
import { Controller, Get } from '@nestjs/common';
|
||||
import { Controller, Get, Param } from '@nestjs/common';
|
||||
|
||||
import { AppService } from './app.service';
|
||||
import { StratumV1Service } from './stratum-v1.service';
|
||||
|
||||
@Controller()
|
||||
export class AppController {
|
||||
constructor(private readonly appService: AppService) {}
|
||||
constructor(private readonly appService: AppService, private readonly stratumV1Service: StratumV1Service) { }
|
||||
|
||||
@Get()
|
||||
getHello(): string {
|
||||
return this.appService.getHello();
|
||||
getInfo() {
|
||||
return {
|
||||
clients: this.stratumV1Service.clients.length
|
||||
}
|
||||
}
|
||||
|
||||
@Get('client/:clientId')
|
||||
getClientInfo(@Param('clientId') clientId: string) {
|
||||
const workers = this.stratumV1Service.clients.filter(client => client.clientAuthorization.address === clientId);
|
||||
return {
|
||||
workers: workers.length,
|
||||
workerIds: workers.map(worker => {
|
||||
return {
|
||||
id: worker.id,
|
||||
bestDifficulty: worker.statistics.bestDifficulty,
|
||||
hashrate: worker.statistics.getHashrate()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@Get('client/:clientId/:workerId')
|
||||
getWorkerInfo(@Param('clientId') clientId: string, @Param('workerId') workerId: string) {
|
||||
const worker = this.stratumV1Service.clients.find(client => client.clientAuthorization.address === clientId && client.id === workerId);
|
||||
return {
|
||||
id: worker.id
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user