Last active
August 25, 2023 05:55
-
-
Save bellflower2015/6f37c3722615be755efdf0f1d465e146 to your computer and use it in GitHub Desktop.
Calculating Genesis Block
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ... snip ... | |
#include <arith_uint256.h> | |
// ... snip ... | |
class CMainParams : public CChainParams { | |
public: | |
CMainParams() { | |
// ... snip ... | |
genesis = CreateGenesisBlock(1534567890, 0, 0x1d00ffff, 1, 50 * COIN); | |
consensus.hashGenesisBlock = uint256S("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); | |
if (true && (genesis.GetHash() != consensus.hashGenesisBlock)) { | |
std::cout << std::string("Begin calculating Mainnet Genesis Block:\n"); | |
arith_uint256 hashTarget = arith_uint256().SetCompact(genesis.nBits); | |
uint256 hash; | |
genesis.nNonce = 0; | |
while (UintToArith256(genesis.GetHash()) > hashTarget) { | |
++genesis.nNonce; | |
if (genesis.nNonce == 0) { | |
std::cout << std::string("NONCE WRAPPED, incrementing time:\n"); | |
++genesis.nTime; | |
} | |
if (genesis.nNonce % 1000 == 0) { | |
std::cout << strNetworkID << " nonce: " << genesis.nNonce << " time: " << genesis.nTime << " hash: " << genesis.GetHash().ToString().c_str() << "\n"; | |
} | |
} | |
std::cout << "Mainnet ---\n"; | |
std::cout << " nonce: " << genesis.nNonce << "\n"; | |
std::cout << " time: " << genesis.nTime << "\n"; | |
std::cout << " hash: " << genesis.GetHash().ToString().c_str() << "\n"; | |
std::cout << " merklehash: " << genesis.hashMerkleRoot.ToString().c_str() << "\n"; | |
std::cout << std::string("Finished calculating Mainnet Genesis Block:\n"); | |
} | |
consensus.hashGenesisBlock = genesis.GetHash(); | |
// ... snip ... | |
} | |
// ... snip ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
you are my hero ;-))