|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- var cryptutil = require("../cryptutil");
-
- var {
- coinb1, coinb2, merkleBranch,
- difficulty, exnounce1, exnounce2, iters
- } = JSON.parse(process.argv[2]);
-
- var start = exnounce2.toString("hex");
-
- coinb1 = Buffer.from(coinb1, "hex");
- coinb2 = Buffer.from(coinb2, "hex");
- exnounce1 = Buffer.from(exnounce1, "hex");
- exnounce2 = Buffer.from(exnounce2, "hex");
-
- difficulty = 3;
-
- var hashes = 0;
- var sd = new Date().getTime();
- for (var i = 0; i < iters; ++i) {
- var coinbase =
- cryptutil.createCoinbase(exnounce1, exnounce2, coinb1, coinb2);
- var cbHash = cryptutil.createCbHash(coinbase);
-
- var success = true;
- for (var i = 0; i < difficulty; ++i) {
- if (cbHash[i] !== 0) {
- success = false;
- break;
- }
- }
-
- hashes += 1;
- var d = new Date().getTime();
- if (d - 2000 >= sd) {
- console.log("h"+Math.floor(hashes / 2));
-
- sd = d;
- hashes = 0;
- }
-
- if (success) {
- console.log("o"+cbHash.toString("hex"));
- process.exit(0);
- }
-
- cryptutil.incbufBE(exnounce2);
- if (exnounce2[0] == 255) {
- console.error("exnounce2[0] reached 255");
- process.exit(1);
- }
- }
-
- console.error("iterated through "+iters);
- process.exit(1);
|