mirror of
https://github.com/benjamin-wilson/public-pool.git
synced 2026-09-29 09:05:06 -07:00
increment ids
This commit is contained in:
+9
-16
@@ -16,7 +16,7 @@ export class MiningJob {
|
||||
public target: string;
|
||||
public merkleRoot: string;
|
||||
|
||||
public job_id: number; // ID of the job. Use this ID while submitting share generated from this job.
|
||||
public job_id: string; // ID of the job. Use this ID while submitting share generated from this job.
|
||||
public prevhash: string; // The hex-encoded previous block hash.
|
||||
public coinb1: string; // The hex-encoded prefix of the coinbase transaction (to precede extra nonce 2).
|
||||
public coinb2: string; //The hex-encoded suffix of the coinbase transaction (to follow extra nonce 2).
|
||||
@@ -32,26 +32,26 @@ export class MiningJob {
|
||||
|
||||
public tree: MerkleTree;
|
||||
|
||||
constructor(blockTemplate: IBlockTemplate) {
|
||||
constructor(id: string, blockTemplate: IBlockTemplate, _cleanJobs: boolean) {
|
||||
|
||||
//console.log(blockTemplate);
|
||||
|
||||
this.job_id = 1;
|
||||
this.job_id = id;
|
||||
this.target = blockTemplate.target;
|
||||
this.prevhash = this.convertToLittleEndian(blockTemplate.previousblockhash);
|
||||
|
||||
this.version = blockTemplate.version;
|
||||
this.nbits = parseInt(blockTemplate.bits, 16);
|
||||
this.ntime = Math.floor(new Date().getTime() / 1000);
|
||||
this.clean_jobs = false;
|
||||
this.clean_jobs = _cleanJobs;
|
||||
|
||||
|
||||
const transactionFees = blockTemplate.transactions.reduce((pre, cur, i, arr) => {
|
||||
return pre + cur.fee;
|
||||
}, 0);
|
||||
const miningReward = this.calculateMiningReward(blockTemplate.height);
|
||||
console.log('TRANSACTION FEES', transactionFees);
|
||||
console.log('MINING REWARD', miningReward);
|
||||
//console.log('TRANSACTION FEES', transactionFees);
|
||||
//console.log('MINING REWARD', miningReward);
|
||||
|
||||
const { coinbasePart1, coinbasePart2 } = this.createCoinbaseTransaction([{ address: '', percentage: 100 }], blockTemplate.height, transactionFees + miningReward);
|
||||
|
||||
@@ -79,10 +79,7 @@ export class MiningJob {
|
||||
this.merkle_branch = this.tree.getProof(coinbaseBuffer).map(p => p.data.toString('hex'));
|
||||
|
||||
|
||||
// let test = this.tree.getRoot();
|
||||
// for (let i = 0; i < test.length; i++) {
|
||||
// console.log(test[i])
|
||||
// }
|
||||
this.constructResponse();
|
||||
|
||||
}
|
||||
|
||||
@@ -99,10 +96,6 @@ export class MiningJob {
|
||||
return currentReward;
|
||||
}
|
||||
|
||||
private bufferToHex(buffer: Buffer): string {
|
||||
return buffer.toString('hex');
|
||||
}
|
||||
|
||||
|
||||
|
||||
private createCoinbaseTransaction(addresses: AddressObject[], blockHeight: number, reward: number): { coinbasePart1: string, coinbasePart2: string } {
|
||||
@@ -149,13 +142,13 @@ export class MiningJob {
|
||||
}
|
||||
|
||||
|
||||
public constructResponse() {
|
||||
private constructResponse() {
|
||||
|
||||
const job = {
|
||||
id: 0,
|
||||
method: eResponseMethod.MINING_NOTIFY,
|
||||
params: [
|
||||
this.job_id.toString(16),
|
||||
this.job_id,
|
||||
this.prevhash,
|
||||
this.coinb1,
|
||||
this.coinb2,
|
||||
|
||||
Reference in New Issue
Block a user