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:
@@ -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()
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user