Saturday, December 2, 2023

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

Within the supply code for the CBlockHeader class, there’s a subject known as nBites.

/** Nodes accumulate new transactions right into a block, hash them right into a hash tree,
 * and scan by way of nonce values to make the block's hash fulfill proof-of-work
 * necessities.  After 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
    // 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 subject. However I noticed the CheckBlockHeader operate utilizing the nBits subject to test proof of labor of the block. So I interpret that it is a illustration of the problem 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?

Related Articles


Please enter your comment!
Please enter your name here

Latest Articles