Eth support

This commit is contained in:
MoneroOcean
2021-01-22 05:55:16 +00:00
parent 7c139874ce
commit 9021066354
2 changed files with 20 additions and 3 deletions

View File

@@ -54,7 +54,14 @@ function getMerkleRoot(transactions) {
let last_epoch_number; let last_epoch_number;
let last_seed_hash; let last_seed_hash;
const diff1 = 0x00000000ff000000000000000000000000000000000000000000000000000000;
module.exports.baseRavenDiff = function() {
return parseInt('0x00000000ff000000000000000000000000000000000000000000000000000000');
};
module.exports.baseEthDiff = function() {
return parseInt('0x00000000ffff0000000000000000000000000000000000000000000000000000');
};
module.exports.RavenBlockTemplate = function(rpcData, poolAddress) { module.exports.RavenBlockTemplate = function(rpcData, poolAddress) {
const poolAddrHash = bitcoin.address.fromBase58Check(poolAddress).hash; const poolAddrHash = bitcoin.address.fromBase58Check(poolAddress).hash;
@@ -128,7 +135,7 @@ module.exports.RavenBlockTemplate = function(rpcData, poolAddress) {
last_epoch_number = epoch_number; last_epoch_number = epoch_number;
} }
const difficulty = parseFloat((diff1 / bignum(rpcData.target, 16).toNumber()).toFixed(9)); const difficulty = parseFloat((module.exports.baseRavenDiff() / bignum(rpcData.target, 16).toNumber()).toFixed(9));
return { return {
blocktemplate_blob: blob.toString('hex'), blocktemplate_blob: blob.toString('hex'),
@@ -139,6 +146,7 @@ module.exports.RavenBlockTemplate = function(rpcData, poolAddress) {
difficulty: difficulty, difficulty: difficulty,
height: rpcData.height, height: rpcData.height,
bits: rpcData.bits, bits: rpcData.bits,
prev_hash: rpcData.previousblockhash,
}; };
}; };
@@ -172,3 +180,12 @@ module.exports.constructNewDeroBlob = function(blockTemplate, nonceBuff) {
nonceBuff.copy(blockTemplate, 39, 0, 4); nonceBuff.copy(blockTemplate, 39, 0, 4);
return blockTemplate; return blockTemplate;
}; };
module.exports.EthBlockTemplate = function(rpcData) {
const difficulty = parseFloat((module.exports.baseEth() / bignum(rpcData[2].lstrip("0x"), 16).toNumber()).toFixed(19));
return {
hash: rpcData[0].lstrip("0x"),
seed_hash: rpcData[1].lstrip("0x"),
difficulty: difficulty
};
};

View File

@@ -1,6 +1,6 @@
{ {
"name": "cryptoforknote-util", "name": "cryptoforknote-util",
"version": "9.0.18", "version": "9.1.0",
"main": "cryptoforknote-util", "main": "cryptoforknote-util",
"author": { "author": {
"name": "LucasJones", "name": "LucasJones",