use PoW hash in test_bitcoin, use pound defs for generating genesis block
This commit is contained in:
parent
e190551cb2
commit
864533c699
2 changed files with 22 additions and 10 deletions
|
@ -18,6 +18,8 @@
|
||||||
#include "chainparamsseeds.h"
|
#include "chainparamsseeds.h"
|
||||||
#include "arith_uint256.h"
|
#include "arith_uint256.h"
|
||||||
|
|
||||||
|
//#define FIND_GENESIS
|
||||||
|
|
||||||
#define GENESIS_MERKLE_ROOT "b8211c82c3d15bcd78bba57005b86fed515149a53a425eb592c07af99fe559cc"
|
#define GENESIS_MERKLE_ROOT "b8211c82c3d15bcd78bba57005b86fed515149a53a425eb592c07af99fe559cc"
|
||||||
|
|
||||||
#define MAINNET_GENESIS_HASH "0000678ddce6b9b57e58fab6b89a1cf63519ffb4bc097debb1836577ead9a3be"
|
#define MAINNET_GENESIS_HASH "0000678ddce6b9b57e58fab6b89a1cf63519ffb4bc097debb1836577ead9a3be"
|
||||||
|
@ -68,7 +70,8 @@ static CBlock CreateGenesisBlock(const char* pszTimestamp, const CScript& genesi
|
||||||
genesis.hashMerkleRoot = BlockMerkleRoot(genesis);
|
genesis.hashMerkleRoot = BlockMerkleRoot(genesis);
|
||||||
genesis.hashClaimTrie = uint256S("0x0000000000000000000000000000000000000000000000000000000000000001");
|
genesis.hashClaimTrie = uint256S("0x0000000000000000000000000000000000000000000000000000000000000001");
|
||||||
|
|
||||||
/*while (true)
|
#ifdef FIND_GENESIS
|
||||||
|
while (true)
|
||||||
{
|
{
|
||||||
genesis.nNonce += 1;
|
genesis.nNonce += 1;
|
||||||
if (CheckProofOfWork2(genesis.GetPoWHash(), nBits, consensus))
|
if (CheckProofOfWork2(genesis.GetPoWHash(), nBits, consensus))
|
||||||
|
@ -78,7 +81,8 @@ static CBlock CreateGenesisBlock(const char* pszTimestamp, const CScript& genesi
|
||||||
std::cout << "pow hash: " << genesis.GetPoWHash().GetHex() << std::endl;
|
std::cout << "pow hash: " << genesis.GetPoWHash().GetHex() << std::endl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
|
#endif
|
||||||
return genesis;
|
return genesis;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,11 +155,13 @@ public:
|
||||||
|
|
||||||
genesis = CreateGenesisBlock(1446058291, MAINNET_GENESIS_NONCE, 0x1f00ffff, 1, 400000000 * COIN, consensus);
|
genesis = CreateGenesisBlock(1446058291, MAINNET_GENESIS_NONCE, 0x1f00ffff, 1, 400000000 * COIN, consensus);
|
||||||
consensus.hashGenesisBlock = genesis.GetHash();
|
consensus.hashGenesisBlock = genesis.GetHash();
|
||||||
//std::cout << "hex: " << consensus.hashGenesisBlock.GetHex() << std::endl;
|
#ifdef FIND_GENESIS
|
||||||
//std::cout << "merkle root: " << genesis.hashMerkleRoot.GetHex() << std::endl;
|
std::cout << "hex: " << consensus.hashGenesisBlock.GetHex() << std::endl;
|
||||||
|
std::cout << "merkle root: " << genesis.hashMerkleRoot.GetHex() << std::endl;
|
||||||
|
#else
|
||||||
assert(consensus.hashGenesisBlock == uint256S(MAINNET_GENESIS_HASH));
|
assert(consensus.hashGenesisBlock == uint256S(MAINNET_GENESIS_HASH));
|
||||||
assert(genesis.hashMerkleRoot == uint256S(GENESIS_MERKLE_ROOT));
|
assert(genesis.hashMerkleRoot == uint256S(GENESIS_MERKLE_ROOT));
|
||||||
|
#endif
|
||||||
vSeeds.clear();
|
vSeeds.clear();
|
||||||
vFixedSeeds.clear();
|
vFixedSeeds.clear();
|
||||||
|
|
||||||
|
@ -225,10 +231,13 @@ public:
|
||||||
|
|
||||||
genesis = CreateGenesisBlock(1446058291, MAINNET_GENESIS_NONCE, 0x1f00ffff, 1, 400000000 * COIN, consensus);
|
genesis = CreateGenesisBlock(1446058291, MAINNET_GENESIS_NONCE, 0x1f00ffff, 1, 400000000 * COIN, consensus);
|
||||||
consensus.hashGenesisBlock = genesis.GetHash();
|
consensus.hashGenesisBlock = genesis.GetHash();
|
||||||
//std::cout << "testnet genesis hash: " << genesis.GetHash().GetHex() << std::endl;
|
#ifdef FIND_GENESIS
|
||||||
//std::cout << "testnet merkle hash: " << genesis.hashMerkleRoot.GetHex() << std::endl;
|
std::cout << "testnet genesis hash: " << genesis.GetHash().GetHex() << std::endl;
|
||||||
|
std::cout << "testnet merkle hash: " << genesis.hashMerkleRoot.GetHex() << std::endl;
|
||||||
|
#else
|
||||||
assert(consensus.hashGenesisBlock == uint256S(MAINNET_GENESIS_HASH));
|
assert(consensus.hashGenesisBlock == uint256S(MAINNET_GENESIS_HASH));
|
||||||
assert(genesis.hashMerkleRoot == uint256S(GENESIS_MERKLE_ROOT));
|
assert(genesis.hashMerkleRoot == uint256S(GENESIS_MERKLE_ROOT));
|
||||||
|
#endif
|
||||||
|
|
||||||
vFixedSeeds.clear();
|
vFixedSeeds.clear();
|
||||||
vSeeds.clear();
|
vSeeds.clear();
|
||||||
|
@ -298,10 +307,13 @@ public:
|
||||||
|
|
||||||
genesis = CreateGenesisBlock(1446058291, REGTEST_GENESIS_NONCE, 0x207fffff, 1, 400000000 * COIN, consensus);
|
genesis = CreateGenesisBlock(1446058291, REGTEST_GENESIS_NONCE, 0x207fffff, 1, 400000000 * COIN, consensus);
|
||||||
consensus.hashGenesisBlock = genesis.GetHash();
|
consensus.hashGenesisBlock = genesis.GetHash();
|
||||||
//std::cout << "regtest genensis hash: " << genesis.GetHash().GetHex() << std::endl;
|
#ifdef FIND_GENESIS
|
||||||
//std::cout << "regtest hashmerkleroot: " << genesis.hashMerkleRoot.GetHex() << std::endl;
|
std::cout << "regtest genensis hash: " << genesis.GetHash().GetHex() << std::endl;
|
||||||
|
std::cout << "regtest hashmerkleroot: " << genesis.hashMerkleRoot.GetHex() << std::endl;
|
||||||
|
#else
|
||||||
assert(consensus.hashGenesisBlock == uint256S(REGTEST_GENESIS_HASH));
|
assert(consensus.hashGenesisBlock == uint256S(REGTEST_GENESIS_HASH));
|
||||||
assert(genesis.hashMerkleRoot == uint256S(GENESIS_MERKLE_ROOT));
|
assert(genesis.hashMerkleRoot == uint256S(GENESIS_MERKLE_ROOT));
|
||||||
|
#endif
|
||||||
|
|
||||||
vFixedSeeds.clear(); //!< Regtest mode doesn't have any fixed seeds.
|
vFixedSeeds.clear(); //!< Regtest mode doesn't have any fixed seeds.
|
||||||
vSeeds.clear(); //!< Regtest mode doesn't have any DNS seeds.
|
vSeeds.clear(); //!< Regtest mode doesn't have any DNS seeds.
|
||||||
|
|
|
@ -136,7 +136,7 @@ TestChain100Setup::CreateAndProcessBlock(const std::vector<CMutableTransaction>&
|
||||||
unsigned int extraNonce = 0;
|
unsigned int extraNonce = 0;
|
||||||
IncrementExtraNonce(&block, chainActive.Tip(), extraNonce);
|
IncrementExtraNonce(&block, chainActive.Tip(), extraNonce);
|
||||||
|
|
||||||
while (!CheckProofOfWork(block.GetHash(), block.nBits, chainparams.GetConsensus())) ++block.nNonce;
|
while (!CheckProofOfWork(block.GetPoWHash(), block.nBits, chainparams.GetConsensus())) ++block.nNonce;
|
||||||
|
|
||||||
CValidationState state;
|
CValidationState state;
|
||||||
ProcessNewBlock(state, chainparams, NULL, &block, true, NULL);
|
ProcessNewBlock(state, chainparams, NULL, &block, true, NULL);
|
||||||
|
|
Loading…
Reference in a new issue