mirror of
https://github.com/benjamin-wilson/public-pool.git
synced 2026-09-29 09:05:06 -07:00
allow client to suggest diff in password field "d=1234"
This commit is contained in:
@@ -217,6 +217,9 @@ export class StratumV1Client {
|
|||||||
|
|
||||||
if (errors.length === 0) {
|
if (errors.length === 0) {
|
||||||
this.clientAuthorization = authorizationMessage;
|
this.clientAuthorization = authorizationMessage;
|
||||||
|
if (this.clientSuggestedDifficulty == null && this.clientAuthorization.startingDiff != null && this.clientAuthorization.startingDiff > this.sessionDifficulty) {
|
||||||
|
this.sessionDifficulty = this.clientAuthorization.startingDiff;
|
||||||
|
}
|
||||||
const success = await this.write(JSON.stringify(this.clientAuthorization.response()) + '\n');
|
const success = await this.write(JSON.stringify(this.clientAuthorization.response()) + '\n');
|
||||||
if (!success) {
|
if (!success) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Expose, Transform } from 'class-transformer';
|
import { Expose, Transform } from 'class-transformer';
|
||||||
import { ArrayMaxSize, ArrayMinSize, IsArray, IsOptional, IsString, MaxLength } from 'class-validator';
|
import { ArrayMaxSize, ArrayMinSize, IsArray, IsNumber, IsOptional, IsString, MaxLength } from 'class-validator';
|
||||||
|
|
||||||
import { eRequestMethod } from '../enums/eRequestMethod';
|
import { eRequestMethod } from '../enums/eRequestMethod';
|
||||||
import { IsBitcoinAddress } from '../validators/bitcoin-address.validator';
|
import { IsBitcoinAddress } from '../validators/bitcoin-address.validator';
|
||||||
@@ -8,7 +8,7 @@ import { StratumBaseMessage } from './StratumBaseMessage';
|
|||||||
export class AuthorizationMessage extends StratumBaseMessage {
|
export class AuthorizationMessage extends StratumBaseMessage {
|
||||||
|
|
||||||
@IsArray()
|
@IsArray()
|
||||||
@ArrayMinSize(2)
|
@ArrayMinSize(1)
|
||||||
@ArrayMaxSize(2)
|
@ArrayMaxSize(2)
|
||||||
params: string[];
|
params: string[];
|
||||||
|
|
||||||
@@ -24,11 +24,28 @@ export class AuthorizationMessage extends StratumBaseMessage {
|
|||||||
@IsString()
|
@IsString()
|
||||||
@MaxLength(64)
|
@MaxLength(64)
|
||||||
@Transform(({ value, key, obj, type }) => {
|
@Transform(({ value, key, obj, type }) => {
|
||||||
return obj.params[0].split('.')[1] == null ? 'worker' : obj.params[0].split('.')[1];
|
const workerName = obj.params[0].split('.')[1];
|
||||||
|
if (workerName == null) {
|
||||||
|
return 'worker';
|
||||||
|
}
|
||||||
|
return workerName;
|
||||||
})
|
})
|
||||||
public worker: string;
|
public worker: string;
|
||||||
|
|
||||||
|
|
||||||
|
@Expose()
|
||||||
|
@IsNumber()
|
||||||
|
@Transform(({ value, key, obj, type }) => {
|
||||||
|
const password: string | null = obj.params[1];
|
||||||
|
if (password?.includes('d=')) {
|
||||||
|
return parseInt(password.split('d=')[1]);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
})
|
||||||
|
@IsOptional()
|
||||||
|
public startingDiff: number;
|
||||||
|
|
||||||
|
|
||||||
@Expose()
|
@Expose()
|
||||||
@IsString()
|
@IsString()
|
||||||
@Transform(({ value, key, obj, type }) => {
|
@Transform(({ value, key, obj, type }) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user