mirror of
https://github.com/benjamin-wilson/public-pool.git
synced 2026-09-29 09:05:06 -07:00
cleanup
This commit is contained in:
@@ -15,24 +15,17 @@ export class MiningJob {
|
|||||||
private coinbasePart1: string;
|
private coinbasePart1: string;
|
||||||
private coinbasePart2: string;
|
private coinbasePart2: string;
|
||||||
|
|
||||||
// private merkle_branch: string[]; // List of hashes, will be used for calculation of merkle root. This is not a list of all transactions, it only contains prepared hashes of steps of merkle tree algorithm.
|
|
||||||
|
|
||||||
public jobId: string; // ID of the job. Use this ID while submitting share generated from this job.
|
|
||||||
public jobTemplateId: string;
|
public jobTemplateId: string;
|
||||||
//public block: bitcoinjs.Block = new bitcoinjs.Block();
|
|
||||||
public networkDifficulty: number;
|
public networkDifficulty: number;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private network: bitcoinjs.networks.Network,
|
private network: bitcoinjs.networks.Network,
|
||||||
id: string,
|
public jobId: string,
|
||||||
payoutInformation: AddressObject[],
|
payoutInformation: AddressObject[],
|
||||||
jobTemplate: IJobTemplate
|
jobTemplate: IJobTemplate
|
||||||
) {
|
) {
|
||||||
|
|
||||||
this.jobId = id;
|
|
||||||
this.jobTemplateId = jobTemplate.blockData.id,
|
this.jobTemplateId = jobTemplate.blockData.id,
|
||||||
|
|
||||||
this.coinbaseTransaction = this.createCoinbaseTransaction(payoutInformation, jobTemplate.blockData.coinbasevalue);
|
this.coinbaseTransaction = this.createCoinbaseTransaction(payoutInformation, jobTemplate.blockData.coinbasevalue);
|
||||||
|
|||||||
@@ -356,18 +356,18 @@ export class StratumV1Client extends EasyUnsubscribe {
|
|||||||
|
|
||||||
if (submissionDifficulty >= this.sessionDifficulty) {
|
if (submissionDifficulty >= this.sessionDifficulty) {
|
||||||
|
|
||||||
if (submissionDifficulty >= job.networkDifficulty) {
|
if (submissionDifficulty >= jobTemplate.blockData.networkDifficulty) {
|
||||||
console.log('!!! BLOCK FOUND !!!');
|
console.log('!!! BLOCK FOUND !!!');
|
||||||
const blockHex = updatedJobBlock.toHex(false);
|
const blockHex = updatedJobBlock.toHex(false);
|
||||||
const result = await this.bitcoinRpcService.SUBMIT_BLOCK(blockHex);
|
const result = await this.bitcoinRpcService.SUBMIT_BLOCK(blockHex);
|
||||||
await this.blocksService.save({
|
await this.blocksService.save({
|
||||||
height: jobTemplate.height,
|
height: jobTemplate.blockData.height,
|
||||||
minerAddress: this.clientAuthorization.address,
|
minerAddress: this.clientAuthorization.address,
|
||||||
worker: this.clientAuthorization.worker,
|
worker: this.clientAuthorization.worker,
|
||||||
sessionId: this.extraNonceAndSessionId,
|
sessionId: this.extraNonceAndSessionId,
|
||||||
blockData: blockHex
|
blockData: blockHex
|
||||||
});
|
});
|
||||||
await this.notificationService.notifySubscribersBlockFound(this.clientAuthorization.address, jobTemplate.height, updatedJobBlock, result);
|
await this.notificationService.notifySubscribersBlockFound(this.clientAuthorization.address, jobTemplate.blockData.height, updatedJobBlock, result);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await this.statistics.addSubmission(this.entity, submissionHash, this.sessionDifficulty);
|
await this.statistics.addSubmission(this.entity, submissionHash, this.sessionDifficulty);
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ export interface IJobTemplate {
|
|||||||
littleEndianBlockHeight: Buffer;
|
littleEndianBlockHeight: Buffer;
|
||||||
coinbasevalue: number;
|
coinbasevalue: number;
|
||||||
networkDifficulty: number;
|
networkDifficulty: number;
|
||||||
|
height: number;
|
||||||
clearJobs: boolean;
|
clearJobs: boolean;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -75,11 +76,12 @@ export class StratumV1JobsService {
|
|||||||
coinbasevalue: blockTemplate.coinbasevalue,
|
coinbasevalue: blockTemplate.coinbasevalue,
|
||||||
timestamp: Math.floor(new Date().getTime() / 1000),
|
timestamp: Math.floor(new Date().getTime() / 1000),
|
||||||
networkDifficulty: this.calculateNetworkDifficulty(parseInt(blockTemplate.bits, 16)),
|
networkDifficulty: this.calculateNetworkDifficulty(parseInt(blockTemplate.bits, 16)),
|
||||||
clearJobs
|
clearJobs,
|
||||||
|
height: blockTemplate.height
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
filter(next => next != null),
|
filter(next => next != null),
|
||||||
map(({ version, bits, prevHash, transactions, timestamp, littleEndianBlockHeight, coinbasevalue, networkDifficulty, clearJobs }) => {
|
map(({ version, bits, prevHash, transactions, timestamp, littleEndianBlockHeight, coinbasevalue, networkDifficulty, clearJobs, height }) => {
|
||||||
const block = new bitcoinjs.Block();
|
const block = new bitcoinjs.Block();
|
||||||
|
|
||||||
//create an empty coinbase tx
|
//create an empty coinbase tx
|
||||||
@@ -119,6 +121,7 @@ export class StratumV1JobsService {
|
|||||||
littleEndianBlockHeight,
|
littleEndianBlockHeight,
|
||||||
coinbasevalue,
|
coinbasevalue,
|
||||||
networkDifficulty,
|
networkDifficulty,
|
||||||
|
height,
|
||||||
clearJobs
|
clearJobs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -151,7 +154,7 @@ export class StratumV1JobsService {
|
|||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getJobTemplateById(jobTemplateId: string) {
|
public getJobTemplateById(jobTemplateId: string): IJobTemplate {
|
||||||
return this.blocks[jobTemplateId];
|
return this.blocks[jobTemplateId];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import { StratumV1JobsService } from './stratum-v1-jobs.service';
|
|||||||
@Injectable()
|
@Injectable()
|
||||||
export class StratumV1Service implements OnModuleInit {
|
export class StratumV1Service implements OnModuleInit {
|
||||||
|
|
||||||
private
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly bitcoinRpcService: BitcoinRpcService,
|
private readonly bitcoinRpcService: BitcoinRpcService,
|
||||||
private readonly clientService: ClientService,
|
private readonly clientService: ClientService,
|
||||||
|
|||||||
Reference in New Issue
Block a user