mirror of
https://github.com/benjamin-wilson/public-pool.git
synced 2026-09-29 17:15:03 -07:00
save work
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import { ArrayMaxSize, ArrayMinSize, IsArray } from 'class-validator';
|
||||
|
||||
import { eRequestMethod } from '../enums/eRequestMethod';
|
||||
import { StratumBaseMessage } from './StratumBaseMessage';
|
||||
|
||||
export class AuthorizationMessage extends StratumBaseMessage {
|
||||
|
||||
@IsArray()
|
||||
@ArrayMinSize(2)
|
||||
@ArrayMaxSize(2)
|
||||
params: string[];
|
||||
|
||||
public username: string;
|
||||
|
||||
public password: string;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.method = eRequestMethod.AUTHORIZE;
|
||||
|
||||
}
|
||||
|
||||
public parse() {
|
||||
this.username = this.params[0];
|
||||
this.password = this.params[1];
|
||||
console.log(`Username ${this.username}, Password: ${this.password}`);
|
||||
}
|
||||
|
||||
public response() {
|
||||
return {
|
||||
id: null,
|
||||
error: null,
|
||||
result: true
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import { IsArray } from 'class-validator';
|
||||
|
||||
import { eRequestMethod } from '../enums/eRequestMethod';
|
||||
import { StratumBaseMessage } from './StratumBaseMessage';
|
||||
|
||||
export class ConfigurationMessage extends StratumBaseMessage {
|
||||
|
||||
@IsArray()
|
||||
params: string[];
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.method = eRequestMethod.CONFIGURE;
|
||||
}
|
||||
|
||||
public response() {
|
||||
return {
|
||||
id: null,
|
||||
error: null,
|
||||
result: {
|
||||
'version-rolling': true,
|
||||
'version-rolling.mask': '1fffe000'
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import { ArrayMaxSize, ArrayMinSize, IsArray } from 'class-validator';
|
||||
|
||||
import { eRequestMethod } from '../enums/eRequestMethod';
|
||||
import { StratumBaseMessage } from './StratumBaseMessage';
|
||||
|
||||
export class MiningSubmitMessage extends StratumBaseMessage {
|
||||
|
||||
@IsArray()
|
||||
@ArrayMinSize(5)
|
||||
@ArrayMaxSize(5)
|
||||
params: string[];
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.method = eRequestMethod.AUTHORIZE;
|
||||
}
|
||||
|
||||
public response() {
|
||||
return {
|
||||
id: null,
|
||||
error: null,
|
||||
result: true
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import { IsEnum, IsNumber } from 'class-validator';
|
||||
|
||||
import { eRequestMethod } from '../enums/eRequestMethod';
|
||||
|
||||
export class StratumBaseMessage {
|
||||
@IsNumber()
|
||||
id: number;
|
||||
@IsEnum(eRequestMethod)
|
||||
method: eRequestMethod;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import { IsArray } from 'class-validator';
|
||||
|
||||
import { eRequestMethod } from '../enums/eRequestMethod';
|
||||
import { StratumBaseMessage } from './StratumBaseMessage';
|
||||
|
||||
export class SubscriptionMessage extends StratumBaseMessage {
|
||||
|
||||
|
||||
@IsArray()
|
||||
params: string[];
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.method = eRequestMethod.SUBSCRIBE;
|
||||
|
||||
console.log('constructor SubscriptionMessage');
|
||||
}
|
||||
|
||||
public response() {
|
||||
return {
|
||||
id: null,
|
||||
error: null,
|
||||
result: [
|
||||
[
|
||||
['mining.notify', '64d8c004']
|
||||
], //subscription details
|
||||
'ccc5d664', //Extranonce1 - Hex-encoded, per-connection unique string which will be used for coinbase serialization later. Keep it safe!
|
||||
8 //Extranonce2_size - Represents expected length of extranonce2 which will be generated by the miner.
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import { ArrayMaxSize, ArrayMinSize, IsArray, IsNumber } from 'class-validator';
|
||||
|
||||
import { eRequestMethod } from '../enums/eRequestMethod';
|
||||
import { eResponseMethod } from '../enums/eResponseMethod';
|
||||
import { StratumBaseMessage } from './StratumBaseMessage';
|
||||
|
||||
export class SuggestDifficulty extends StratumBaseMessage {
|
||||
@IsArray()
|
||||
@ArrayMinSize(1)
|
||||
@ArrayMaxSize(1)
|
||||
@IsNumber({}, { each: true })
|
||||
params: string[];
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.method = eRequestMethod.SUGGEST_DIFFICULTY;
|
||||
}
|
||||
|
||||
public response() {
|
||||
return {
|
||||
id: null,
|
||||
method: eResponseMethod.SET_DIFFICULTY,
|
||||
params: [1024]
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user