pub fn body_matches_header(block: &Block) -> Result<(), BlockError>Expand description
Returns Ok(()) if block’s header commits to its transaction IDs, and to the height in its
coinbase input, if it has one.
A peer that serves a requested block hash can send any body with the header. This shows whether the body’s coinbase height is the block’s real height, without any state, so it works for a block whose parent isn’t known. It catches every change to a transaction ID, and a rewritten height in a V5 or later coinbase. It doesn’t check that the block is valid, or catch other changes to V5 authorizing data, or duplicated transactions, which keep the coinbase.
It hashes the transaction IDs into a Merkle root. The IDs are computed when the block is deserialized, so this costs much less than deserializing the block. But the block verifiers compute the same root, so only call it before using a block’s height without verifying the block.