creatorLee

create genesis example code

Feb 22nd, 2018
422
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if (true && (genesis.GetHash() != consensus.hashGenesisBlock)) {
  2. LogPrintf("Calculating Mainnet Genesis Block:\n");
  3. arith_uint256 hashTarget = arith_uint256().SetCompact(genesis.nBits);
  4. uint256 hash;
  5. genesis.nNonce = 0;
  6. // while (genesis.GetHash() > hashTarget)
  7. while (UintToArith256(genesis.GetHash()) > hashTarget)
  8. {
  9. ++genesis.nNonce;
  10. if (genesis.nNonce == 0)
  11. {
  12. LogPrintf("NONCE WRAPPED, incrementing time");
  13. std::cout << std::string("NONCE WRAPPED, incrementing time:\n");
  14. ++genesis.nTime;
  15. }
  16. if (genesis.nNonce % 10000 == 0)
  17. {
  18. LogPrintf("Mainnet: nonce %08u: hash = %s \n", genesis.nNonce, genesis.GetHash().ToString().c_str());
  19. // std::cout << strNetworkID << " nonce: " << genesis.nNonce << " time: " << genesis.nTime << " hash: " << genesis.GetHash().ToString().c_str() << "\n";
  20. }
  21.  
  22. }
  23. std::cout << "Mainnet ---\n";
  24. std::cout << " nonce: " << genesis.nNonce << "\n";
  25. std::cout << " time: " << genesis.nTime << "\n";
  26. std::cout << " Genesis hash: " << genesis.GetHash().ToString().c_str() << "\n";
  27. std::cout << " Genesis merklehash: " << genesis.hashMerkleRoot.ToString().c_str() << "\n";
  28. // Mainnet --- nonce: 296277 time: 1390095618 hash: 000000bdd771b14e5a031806292305e563956ce2584278de414d9965f6ab54b0
  29. }
RAW Paste Data