Skip to content

Commit 497651a

Browse files
author
Alexander Blair
committed
Hashing-Add: RandomX
Should complete support for RandomX
1 parent 672137a commit 497651a

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

lib/xmr.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +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;
5859
if (typeof (this.workerOffset) === 'undefined') {
5960
this.solo = true;
6061
global.instanceId.copy(this.buffer, this.reservedOffset + 4, 0, 3);
@@ -91,6 +92,7 @@ function MasterBlockTemplate(template) {
9192
this.workerNonce = 0;
9293
this.poolNonce = 0;
9394
this.solo = false;
95+
this.seedHash = template.seed_hash;
9496
if (typeof (this.workerOffset) === 'undefined') {
9597
this.solo = true;
9698
global.instanceId.copy(this.buffer, this.reservedOffset + 4, 0, 3);
@@ -191,7 +193,11 @@ function processShare(miner, job, blockTemplate, nonce, resultHash) {
191193
// Validate share with CN hash, then if valid, blast it up to the master.
192194
let shareBuffer = cnUtil.construct_block_blob(template, new Buffer(nonce, 'hex'));
193195
let convertedBlob = cnUtil.convert_blob(shareBuffer);
194-
hash = multiHashing.cryptonight(convertedBlob, convertedBlob[0] >= 10 ? 13 : 8, job.height);
196+
if (blockTemplate.seedHash == null || blockTemplate.seedHash !== Buffer.from('00', 'hex')) {
197+
hash = multiHashing.cryptonight(convertedBlob, convertedBlob[0] >= 10 ? 13 : 8, job.height);
198+
} else {
199+
hash = multiHashing.randomx(convertedBlob, blockTemplate.seedHash, 0);
200+
}
195201
if (hash.toString("hex") !== resultHash) {
196202
if (multiHashing.cryptonight(convertedBlob, 0).toString("hex") === resultHash) {
197203
console.error(`${global.threadName} Invalid version of CN hashing algo (CN/0) used by miner ${miner.logString}`);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@
3838
"optionalDependencies": {
3939
"cryptonote-util": "git://github.com/Snipa22/node-cryptonote-util.git#xmr-Nan-2.0",
4040
"multi-hashing": "git+https://github.com/Snipa22/node-multi-hashing-aesni.git#v0.1",
41-
"cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v8.0.0"
41+
"cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#865a1f18e7dd5cf0513ae6becfdbeba3a10c9fb9"
4242
}
4343
}

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