mirror of
https://github.com/benjamin-wilson/public-pool.git
synced 2026-09-29 09:05:06 -07:00
class-transformer work
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import Big from 'big.js';
|
||||
import { ArrayMaxSize, ArrayMinSize, IsArray } from 'class-validator';
|
||||
import { Expose, Transform } from 'class-transformer';
|
||||
import { ArrayMaxSize, ArrayMinSize, IsArray, IsString } from 'class-validator';
|
||||
import * as crypto from 'crypto';
|
||||
|
||||
import { eRequestMethod } from '../enums/eRequestMethod';
|
||||
@@ -13,11 +14,41 @@ export class MiningSubmitMessage extends StratumBaseMessage {
|
||||
@ArrayMaxSize(6)
|
||||
public params: string[];
|
||||
|
||||
@Expose()
|
||||
@IsString()
|
||||
@Transform(({ value, key, obj, type }) => {
|
||||
return obj.params[0];
|
||||
})
|
||||
public userId: string;
|
||||
@Expose()
|
||||
@IsString()
|
||||
@Transform(({ value, key, obj, type }) => {
|
||||
return obj.params[1];
|
||||
})
|
||||
public jobId: string;
|
||||
@Expose()
|
||||
@IsString()
|
||||
@Transform(({ value, key, obj, type }) => {
|
||||
return obj.params[2];
|
||||
})
|
||||
public extraNonce2: string;
|
||||
@Expose()
|
||||
@IsString()
|
||||
@Transform(({ value, key, obj, type }) => {
|
||||
return obj.params[3];
|
||||
})
|
||||
public ntime: string;
|
||||
@Expose()
|
||||
@IsString()
|
||||
@Transform(({ value, key, obj, type }) => {
|
||||
return obj.params[4];
|
||||
})
|
||||
public nonce: string
|
||||
@Expose()
|
||||
@IsString()
|
||||
@Transform(({ value, key, obj, type }) => {
|
||||
return obj.params[5];
|
||||
})
|
||||
public versionMask: string;
|
||||
constructor() {
|
||||
super();
|
||||
@@ -25,15 +56,6 @@ export class MiningSubmitMessage extends StratumBaseMessage {
|
||||
}
|
||||
|
||||
|
||||
public parse() {
|
||||
this.userId = this.params[0];
|
||||
this.jobId = this.params[1];
|
||||
this.extraNonce2 = this.params[2];
|
||||
this.ntime = this.params[3];
|
||||
this.nonce = this.params[4];
|
||||
this.versionMask = this.params[5];
|
||||
}
|
||||
|
||||
public response() {
|
||||
return {
|
||||
id: null,
|
||||
|
||||
Reference in New Issue
Block a user