From a8d384aedabcda6007a574e7905d16bb69c96d45 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Tue, 7 Jun 2016 16:06:25 +1200 Subject: [PATCH] Add a 256-bit reserved field to the block header This field has no defined semantics. While it was added as a result of discussions about merged mining in #724, this field will not necessarily ever be used for that purpose. --- src/chain.h | 6 ++++++ src/miner.cpp | 1 + src/primitives/block.cpp | 3 ++- src/primitives/block.h | 5 +++++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/chain.h b/src/chain.h index 05b030267..d8ec961bb 100644 --- a/src/chain.h +++ b/src/chain.h @@ -141,6 +141,7 @@ public: //! block header int nVersion; uint256 hashMerkleRoot; + uint256 hashReserved; unsigned int nTime; unsigned int nBits; uint256 nNonce; @@ -166,6 +167,7 @@ public: nVersion = 0; hashMerkleRoot = uint256(); + hashReserved = uint256(); nTime = 0; nBits = 0; nNonce = uint256(); @@ -183,6 +185,7 @@ public: nVersion = block.nVersion; hashMerkleRoot = block.hashMerkleRoot; + hashReserved = block.hashReserved; nTime = block.nTime; nBits = block.nBits; nNonce = block.nNonce; @@ -214,6 +217,7 @@ public: if (pprev) block.hashPrevBlock = pprev->GetBlockHash(); block.hashMerkleRoot = hashMerkleRoot; + block.hashReserved = hashReserved; block.nTime = nTime; block.nBits = nBits; block.nNonce = nNonce; @@ -321,6 +325,7 @@ public: READWRITE(this->nVersion); READWRITE(hashPrev); READWRITE(hashMerkleRoot); + READWRITE(hashReserved); READWRITE(nTime); READWRITE(nBits); READWRITE(nNonce); @@ -333,6 +338,7 @@ public: block.nVersion = nVersion; block.hashPrevBlock = hashPrev; block.hashMerkleRoot = hashMerkleRoot; + block.hashReserved = hashReserved; block.nTime = nTime; block.nBits = nBits; block.nNonce = nNonce; diff --git a/src/miner.cpp b/src/miner.cpp index 4770abd04..614d97efe 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -354,6 +354,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) // Fill in header pblock->hashPrevBlock = pindexPrev->GetBlockHash(); + pblock->hashReserved = uint256(); UpdateTime(pblock, Params().GetConsensus(), pindexPrev); pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus()); pblock->nNonce = uint256(); diff --git a/src/primitives/block.cpp b/src/primitives/block.cpp index b79859d21..c2300c82a 100644 --- a/src/primitives/block.cpp +++ b/src/primitives/block.cpp @@ -112,11 +112,12 @@ uint256 CBlock::CheckMerkleBranch(uint256 hash, const std::vector& vMer std::string CBlock::ToString() const { std::stringstream s; - s << strprintf("CBlock(hash=%s, ver=%d, hashPrevBlock=%s, hashMerkleRoot=%s, nTime=%u, nBits=%08x, nNonce=%s, vtx=%u)\n", + s << strprintf("CBlock(hash=%s, ver=%d, hashPrevBlock=%s, hashMerkleRoot=%s, hashReserved=%s, nTime=%u, nBits=%08x, nNonce=%s, vtx=%u)\n", GetHash().ToString(), nVersion, hashPrevBlock.ToString(), hashMerkleRoot.ToString(), + hashReserved.ToString(), nTime, nBits, nNonce.ToString(), vtx.size()); for (unsigned int i = 0; i < vtx.size(); i++) diff --git a/src/primitives/block.h b/src/primitives/block.h index 9886bfe8b..0438ae70f 100644 --- a/src/primitives/block.h +++ b/src/primitives/block.h @@ -25,6 +25,7 @@ public: int32_t nVersion; uint256 hashPrevBlock; uint256 hashMerkleRoot; + uint256 hashReserved; uint32_t nTime; uint32_t nBits; uint256 nNonce; @@ -43,6 +44,7 @@ public: nVersion = this->nVersion; READWRITE(hashPrevBlock); READWRITE(hashMerkleRoot); + READWRITE(hashReserved); READWRITE(nTime); READWRITE(nBits); READWRITE(nNonce); @@ -54,6 +56,7 @@ public: nVersion = CBlockHeader::CURRENT_VERSION; hashPrevBlock.SetNull(); hashMerkleRoot.SetNull(); + hashReserved.SetNull(); nTime = 0; nBits = 0; nNonce = uint256(); @@ -115,6 +118,7 @@ public: block.nVersion = nVersion; block.hashPrevBlock = hashPrevBlock; block.hashMerkleRoot = hashMerkleRoot; + block.hashReserved = hashReserved; block.nTime = nTime; block.nBits = nBits; block.nNonce = nNonce; @@ -155,6 +159,7 @@ public: nVersion = this->nVersion; READWRITE(hashPrevBlock); READWRITE(hashMerkleRoot); + READWRITE(hashReserved); READWRITE(nTime); READWRITE(nBits); }