Browse Source

Fixed functional test cnHeader merkle root.

cn_mining
Jianping Wu 5 years ago
parent
commit
991678d552
  1. 2
      src/miner.cpp
  2. 3
      test/functional/test_framework/blocktools.py
  3. 3
      test/functional/test_framework/messages.py

2
src/miner.cpp

@ -176,6 +176,8 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc @@ -176,6 +176,8 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc
UpdateTime(pblock, chainparams.GetConsensus(), pindexPrev);
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, chainparams.GetConsensus());
pblock->nNonce = nHeight; // nNonce now holds the height for Cryptonight variant 4
pblock->cnHeader.major_version = Params().GetConsensus().GetCryptonoteMajorVersion();
pblock->cnHeader.prev_id = pblock->GetOriginalBlockHash();
pblocktemplate->vTxSigOpsCost[0] = WITNESS_SCALE_FACTOR * GetLegacySigOpCount(*pblock->vtx[0]);
CValidationState state;

3
test/functional/test_framework/blocktools.py

@ -42,7 +42,8 @@ def create_block(hashprev, coinbase, nTime=None): @@ -42,7 +42,8 @@ def create_block(hashprev, coinbase, nTime=None):
assert block.nNonce > 0
block.major_version = 10 # CN variant 4
block.timestamp = block.nTime
# Give merkle root a random value.
block.merkle_root = uint256_from_str(bytes.fromhex("3cf6c3b6da3f4058853ee70369ee43d473aca91ae8fc8f44a645beb21c392d80"))
block.calc_sha256()
return block

3
test/functional/test_framework/messages.py

@ -630,9 +630,6 @@ class CBlockHeader(): @@ -630,9 +630,6 @@ class CBlockHeader():
c += ser_uint256(self.prev_id)
c += struct.pack("<I", self.nonce)
# hardcoded merkle root.
self.merkle_root = uint256_from_str(bytes.fromhex("3cf6c3b6da3f4058853ee70369ee43d473aca91ae8fc8f44a645beb21c392d80"))
c += ser_uint256(self.merkle_root)
c += struct.pack("<B", self.nTxes)
# self.sha256 stores the cn_fast hash.

Loading…
Cancel
Save