mirror of
https://github.com/benjamin-wilson/public-pool.git
synced 2026-09-29 09:05:06 -07:00
extra to coinbase script, low diff support
This commit is contained in:
@@ -49,9 +49,9 @@ export class MiningJob {
|
||||
// 32-byte - Commitment hash: Double-SHA256(witness root hash|witness reserved value)
|
||||
|
||||
// 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\\');
|
||||
//coinbaseTransaction.addOutput(bitcoinjs.script.compile([bitcoinjs.opcodes.OP_RETURN, Buffer.concat([segwitMagicBits, this.block.witnessCommit, extra])]), 0);
|
||||
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])]), 0);
|
||||
|
||||
// get the non-witness coinbase tx
|
||||
|
||||
@@ -367,7 +367,7 @@ export class StratumV1Client extends EasyUnsubscribe {
|
||||
worker: this.clientAuthorization.worker,
|
||||
sessionId: this.extraNonce,
|
||||
blockData: blockHex
|
||||
})
|
||||
});
|
||||
await this.notificationService.notifySubscribersBlockFound(this.clientAuthorization.address, job.blockTemplate.height, updatedJobBlock, result);
|
||||
}
|
||||
try {
|
||||
|
||||
@@ -64,6 +64,9 @@ export class StratumV1ClientStatistics {
|
||||
}
|
||||
|
||||
private nearestPowerOfTwo(val) {
|
||||
if (val === 0) {
|
||||
return null;
|
||||
}
|
||||
let x = val | (val >> 1);
|
||||
x = x | (x >> 2);
|
||||
x = x | (x >> 4);
|
||||
@@ -71,17 +74,8 @@ export class StratumV1ClientStatistics {
|
||||
x = x | (x >> 16);
|
||||
x = x | (x >> 32);
|
||||
const res = x - (x >> 1);
|
||||
if (res < 1) {
|
||||
if (val < 0.01) {
|
||||
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;
|
||||
if (res == 0) {
|
||||
return this.nearestPowerOfTwo(val * 100) / 100;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user