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

return root; return root;
} }


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

// sha 512


//ripemd160

// double sha256

return hash;
}

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

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

exnounce1 = Buffer.from(exnounce1, "hex"); exnounce1 = Buffer.from(exnounce1, "hex");
exnounce2 = Buffer.from(exnounce2, "hex"); exnounce2 = Buffer.from(exnounce2, "hex");



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


var hashes = 0; var hashes = 0;
cryptutil.createCoinbase(exnounce1, exnounce2, coinb1, coinb2); cryptutil.createCoinbase(exnounce1, exnounce2, coinb1, coinb2);
var cbHash = cryptutil.createCbHash(coinbase); var cbHash = cryptutil.createCbHash(coinbase);


//build merkle root
//create block header


//check block header starts with 0000
var success = true; var success = true;
for (var i = 0; i < difficulty; ++i) { for (var i = 0; i < difficulty; ++i) {
if (cbHash[i] !== 0) { if (cbHash[i] !== 0) {


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



+ 3
- 3
script.js View File

var CPUMiner = require("./js/miner-cpu"); var CPUMiner = require("./js/miner-cpu");
var ASICMiner = require("./js/miner-asic"); 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() { async function main() {
dns.lookup(domain, async (err, ip) => { dns.lookup(domain, async (err, ip) => {
var c = new StratumClient(ip, port, m); var c = new StratumClient(ip, port, m);
try { try {
await c.connect(); await c.connect();
await c.auth("mort96.worker1", "test");
await c.auth("kattemjau.test", "test");
} catch (err) { } catch (err) {
console.log(err); console.log(err);
process.exit(1); process.exit(1);

Loading…
Cancel
Save