Skip to content

Commit 91b22c4

Browse files
author
Alexander Blair
committed
BT-Fix: Buffer load in BT
1 parent a56d20a commit 91b22c4

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/xmr.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ function BlockTemplate(template) {
5555
this.previousHash = new Buffer(32);
5656
this.workerNonce = 0;
5757
this.solo = false;
58-
this.seedHash = template.seed_hash;
58+
this.seedHash = template.seed_hash ? Buffer.from(template.seed_hash, 'hex') : Buffer.from('00', 'hex');
5959
if (typeof (this.workerOffset) === 'undefined') {
6060
this.solo = true;
6161
global.instanceId.copy(this.buffer, this.reservedOffset + 4, 0, 3);
@@ -92,7 +92,7 @@ function MasterBlockTemplate(template) {
9292
this.workerNonce = 0;
9393
this.poolNonce = 0;
9494
this.solo = false;
95-
this.seedHash = template.seed_hash;
95+
this.seedHash = template.seed_hash ? Buffer.from(template.seed_hash, 'hex') : Buffer.from('00', 'hex');
9696
if (typeof (this.workerOffset) === 'undefined') {
9797
this.solo = true;
9898
global.instanceId.copy(this.buffer, this.reservedOffset + 4, 0, 3);
@@ -197,10 +197,11 @@ function processShare(miner, job, blockTemplate, nonce, resultHash) {
197197
// Validate share with CN hash, then if valid, blast it up to the master.
198198
let shareBuffer = cnUtil.construct_block_blob(template, new Buffer(nonce, 'hex'));
199199
let convertedBlob = cnUtil.convert_blob(shareBuffer);
200-
if (blockTemplate.seedHash == null || blockTemplate.seedHash === Buffer.from('00', 'hex')) {
200+
let nulbuf = Buffer.from('00', 'hex');
201+
if (blockTemplate.seedHash == null || blockTemplate.seedHash === nulbuf) {
201202
hash = multiHashing.cryptonight(convertedBlob, convertedBlob[0] >= 10 ? 13 : 8, job.height);
202203
} else {
203-
hash = multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seedHash, 'hex'), 0);
204+
hash = multiHashing.randomx(convertedBlob, blockTemplate.seedHash, 0);
204205
}
205206
if (hash.toString("hex") !== resultHash) {
206207
if (multiHashing.cryptonight(convertedBlob, 0).toString("hex") === resultHash) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy