bitcoin core growth – What’s the nBits area within the CBlockHeader class?

0
67


Within the supply code for the CBlockHeader class, there’s a area referred to as nBits.

/** Nodes gather new transactions right into a block, hash them right into a hash tree,
 * and scan by means of nonce values to make the block's hash fulfill proof-of-work
 * necessities.  Once they remedy the proof-of-work, they broadcast the block
 * to everybody and the block is added to the block chain.  The primary transaction
 * within the block is a particular one which creates a brand new coin owned by the creator
 * of the block.
 */
class CBlockHeader
{
public:
    // header
    int32_t nVersion;
    uint256 hashPrevBlock;
    uint256 hashMerkleRoot;
    uint32_t nTime;
    uint32_t nBits;
    uint32_t nNonce;

So far as I searched within the code, I did not discovered any remark for this area. However I noticed the CheckBlockHeader perform utilizing the nBits area to verify proof of labor of the block. So I interpret that it is a illustration of the issue for the block.

static bool CheckBlockHeader(const CBlockHeader& block, BlockValidationState& state, const Consensus::Params& consensusParams, bool fCheckPOW = true)
{
    // Verify proof of labor matches claimed quantity
    if (fCheckPOW && !CheckProofOfWork(block.GetHash(), block.nBits, consensusParams))
        return state.Invalid(BlockValidationResult::BLOCK_INVALID_HEADER, "high-hash", "proof of labor failed");

    return true;
}

Is my understanding appropriate?

LEAVE A REPLY

Please enter your comment!
Please enter your name here