extra to coinbase script, low diff support

This commit is contained in:
Ben Wilson
2023-07-13 09:28:34 -04:00
parent ddc7907919
commit 602449625b
4 changed files with 11 additions and 16 deletions
+2 -1
View File
@@ -1,9 +1,10 @@
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm'; import { Column, Entity, Index, PrimaryGeneratedColumn } from 'typeorm';
import { DateTimeTransformer } from '../utils/DateTimeTransformer'; import { DateTimeTransformer } from '../utils/DateTimeTransformer';
import { TrackedEntity } from '../utils/TrackedEntity.entity'; import { TrackedEntity } from '../utils/TrackedEntity.entity';
@Entity() @Entity()
@Index(['address', 'clientName', 'sessionId'], { unique: true })
export class ClientEntity extends TrackedEntity { export class ClientEntity extends TrackedEntity {
@PrimaryGeneratedColumn() @PrimaryGeneratedColumn()
+3 -3
View File
@@ -49,9 +49,9 @@ export class MiningJob {
// 32-byte - Commitment hash: Double-SHA256(witness root hash|witness reserved value) // 32-byte - Commitment hash: Double-SHA256(witness root hash|witness reserved value)
// 39th byte onwards: Optional data with no consensus meaning // 39th byte onwards: Optional data with no consensus meaning
coinbaseTransaction.ins[0].script = Buffer.concat([Buffer.from([littleEndianBlockHeight.byteLength]), littleEndianBlockHeight, Buffer.alloc(8, 0)]); const extra = Buffer.from('\\public-pool\\');
//const extra = Buffer.from('\\public-pool\\'); coinbaseTransaction.ins[0].script = Buffer.concat([Buffer.from([littleEndianBlockHeight.byteLength]), littleEndianBlockHeight, extra, Buffer.alloc(8, 0)]);
//coinbaseTransaction.addOutput(bitcoinjs.script.compile([bitcoinjs.opcodes.OP_RETURN, Buffer.concat([segwitMagicBits, this.block.witnessCommit, extra])]), 0);
coinbaseTransaction.addOutput(bitcoinjs.script.compile([bitcoinjs.opcodes.OP_RETURN, Buffer.concat([segwitMagicBits, this.block.witnessCommit])]), 0); coinbaseTransaction.addOutput(bitcoinjs.script.compile([bitcoinjs.opcodes.OP_RETURN, Buffer.concat([segwitMagicBits, this.block.witnessCommit])]), 0);
// get the non-witness coinbase tx // get the non-witness coinbase tx
+1 -1
View File
@@ -367,7 +367,7 @@ export class StratumV1Client extends EasyUnsubscribe {
worker: this.clientAuthorization.worker, worker: this.clientAuthorization.worker,
sessionId: this.extraNonce, sessionId: this.extraNonce,
blockData: blockHex blockData: blockHex
}) });
await this.notificationService.notifySubscribersBlockFound(this.clientAuthorization.address, job.blockTemplate.height, updatedJobBlock, result); await this.notificationService.notifySubscribersBlockFound(this.clientAuthorization.address, job.blockTemplate.height, updatedJobBlock, result);
} }
try { try {
+5 -11
View File
@@ -64,6 +64,9 @@ export class StratumV1ClientStatistics {
} }
private nearestPowerOfTwo(val) { private nearestPowerOfTwo(val) {
if (val === 0) {
return null;
}
let x = val | (val >> 1); let x = val | (val >> 1);
x = x | (x >> 2); x = x | (x >> 2);
x = x | (x >> 4); x = x | (x >> 4);
@@ -71,17 +74,8 @@ export class StratumV1ClientStatistics {
x = x | (x >> 16); x = x | (x >> 16);
x = x | (x >> 32); x = x | (x >> 32);
const res = x - (x >> 1); const res = x - (x >> 1);
if (res < 1) { if (res == 0) {
if (val < 0.01) { return this.nearestPowerOfTwo(val * 100) / 100;
return 0.01;
}
let y = (val * 100) | ((val * 100) >> 1);
y = y | (y >> 2);
y = y | (y >> 4);
y = y | (y >> 8);
y = y | (y >> 16);
y = y | (y >> 32);
return (y - (y >> 1)) / 100;
} }
return res; return res;
} }