mining.configure optional

This commit is contained in:
Ben Wilson
2023-07-11 17:37:39 -04:00
parent ead1021dd6
commit 978a13a256
8 changed files with 572 additions and 12 deletions
View File
View File
View File
+1
View File
@@ -34,6 +34,7 @@ const ORMModules = [
database: './DB/public-pool.sqlite',
synchronize: true,
autoLoadEntities: true,
cache: true,
logging: false
}),
CacheModule.register(),
+20 -2
View File
@@ -1,4 +1,22 @@
import { Controller } from '@nestjs/common';
import { Controller, Patch } from '@nestjs/common';
import * as bitcoinMessage from 'bitcoinjs-message';
@Controller('address')
export class AddressController {}
export class AddressController {
@Patch('settings')
async settings() {
const publicKey = '...'; // Public key corresponding to the private key used for signing
const message = '...'; // The message that was signed
const signature = '...'; // The signature of the message
const isValid: boolean = bitcoinMessage.verify(message, publicKey, signature);
if (isValid) {
console.log('Signature is valid!');
} else {
console.log('Signature is not valid!');
}
}
}
+18 -10
View File
@@ -77,7 +77,7 @@ export class StratumV1Client extends EasyUnsubscribe {
private async handleMessage(message: string) {
console.log('Received:', message);
console.log(`Received from ${this.extraNonce}`, message);
// Parse the message and check if it's the initial subscription message
let parsedMessage = null;
@@ -248,7 +248,7 @@ export class StratumV1Client extends EasyUnsubscribe {
if (this.clientSubscription != null
&& this.clientConfiguration != null
// && this.clientConfiguration != null
&& this.clientAuthorization != null
&& this.stratumInitialized == false) {
@@ -298,14 +298,22 @@ export class StratumV1Client extends EasyUnsubscribe {
private async sendNewMiningJob(blockTemplate: IBlockTemplate, clearJobs: boolean) {
const payoutInformation = [
{ address: 'tb1qumezefzdeqqwn5zfvgdrhxjzc5ylr39uhuxcz4', percent: 1.8 },
{ address: this.clientAuthorization.address, percent: 98.2 }
];
const hashRate = await this.clientStatisticsService.getHashRateForSession(this.clientAuthorization.address, this.clientAuthorization.worker, this.extraNonce);
// const payoutInformation = [
// { address: this.clientAuthorization.address, percent: 100 }
// ];
let payoutInformation;
//10Th/s
const noFee = hashRate < 10000000000000;
if (noFee) {
payoutInformation = [
{ address: this.clientAuthorization.address, percent: 100 }
];
} else {
payoutInformation = [
{ address: 'tb1qumezefzdeqqwn5zfvgdrhxjzc5ylr39uhuxcz4', percent: 1.5 },
{ address: this.clientAuthorization.address, percent: 98.5 }
];
}
const job = new MiningJob(this.stratumV1JobsService.getNextId(), payoutInformation, blockTemplate, clearJobs);
@@ -314,7 +322,7 @@ export class StratumV1Client extends EasyUnsubscribe {
await this.promiseSocket.write(job.response());
console.log(`Sent new job to ${this.extraNonce}. (clearJobs: ${clearJobs})`)
console.log(`Sent new job to ${this.extraNonce}. (clearJobs: ${clearJobs}, fee?: ${!noFee})`)
}