Browse Source

this

master
kattemjau 6 years ago
parent
commit
1be2470cfa
3 changed files with 25 additions and 3 deletions
  1. 14
    0
      js/cryptutil.js
  2. 8
    0
      js/miner-cpu/mining-process.js
  3. 3
    3
      script.js

+ 14
- 0
js/cryptutil.js View File

@@ -50,6 +50,20 @@ function buildMerkleRoot(merkleBranch, cbHash) {
return root;
}

function hashLbry(blockHeader){
//double sha256
var hash = doublesha(blockHeader)

// sha 512


//ripemd160

// double sha256

return hash;
}

/* Run sha256 twice on a buffer.
*
* Returns:

+ 8
- 0
js/miner-cpu/mining-process.js View File

@@ -12,6 +12,8 @@ coinb2 = Buffer.from(coinb2, "hex");
exnounce1 = Buffer.from(exnounce1, "hex");
exnounce2 = Buffer.from(exnounce2, "hex");


//stratnum difficulty = nbits "encoded current network difficulty"
difficulty = 5;

var hashes = 0;
@@ -21,6 +23,11 @@ for (var i = 0; i < iters; ++i) {
cryptutil.createCoinbase(exnounce1, exnounce2, coinb1, coinb2);
var cbHash = cryptutil.createCbHash(coinbase);

//build merkle root
//create block header


//check block header starts with 0000
var success = true;
for (var i = 0; i < difficulty; ++i) {
if (cbHash[i] !== 0) {
@@ -40,6 +47,7 @@ for (var i = 0; i < iters; ++i) {

if (success) {
console.log("o"+cbHash.toString("hex"));
//send hash back to server
process.exit(0);
}


+ 3
- 3
script.js View File

@@ -11,8 +11,8 @@ var StratumClient = require("./js/stratum-client");
var CPUMiner = require("./js/miner-cpu");
var ASICMiner = require("./js/miner-asic");

var domain = "stratum.slushpool.com"
var port = 3333;
var domain = "lbry.suprnova.cc"
var port = 6256;

async function main() {
dns.lookup(domain, async (err, ip) => {
@@ -22,7 +22,7 @@ async function main() {
var c = new StratumClient(ip, port, m);
try {
await c.connect();
await c.auth("mort96.worker1", "test");
await c.auth("kattemjau.test", "test");
} catch (err) {
console.log(err);
process.exit(1);

Loading…
Cancel
Save