pub enum DiskBlockHeader {
FullyValid(Header, u32),
AssumedValid(Header, u32),
Orphan(Header),
HeadersOnly(Header, u32),
InFork(Header, u32),
InvalidChain(Header),
}Expand description
This enum is used to store a block header in the database. It contains the header along with metadata about the validation state of the block, and, if applicable, also its height.
Variants§
FullyValid(Header, u32)
Represents a fully validated block header in the current best chain.
AssumedValid(Header, u32)
Represents an assumed valid block header.
Orphan(Header)
Represents an orphan block header.
HeadersOnly(Header, u32)
Represents a block header in the current best chain whose block is pending validation.
InFork(Header, u32)
Represents a block header in a fork.
InvalidChain(Header)
Represents an invalid chain block header.
Implementations§
Source§impl DiskBlockHeader
impl DiskBlockHeader
Sourcepub fn block_hash(&self) -> BlockHash
pub fn block_hash(&self) -> BlockHash
Computes the block hash.
Sourcepub fn height(&self) -> Option<u32>
pub fn height(&self) -> Option<u32>
Gets the block height or returns None if the block is orphaned or on an invalid chain.
Sourcepub fn try_height(&self) -> Result<u32, BlockchainError>
pub fn try_height(&self) -> Result<u32, BlockchainError>
Gets the block height or returns BlockchainError::OrphanOrInvalidBlock if the block is
orphaned or on an invalid chain (the height is not stored).
Methods from Deref<Target = BlockHeader>§
pub const SIZE: usize = 80usize
pub fn block_hash(&self) -> BlockHash
pub fn block_hash(&self) -> BlockHash
Returns the block hash.
pub fn target(&self) -> Target
pub fn target(&self) -> Target
Computes the target (range [0, T] inclusive) that a blockhash must land in to be valid.
pub fn difficulty(&self, params: impl AsRef<Params>) -> u128
pub fn difficulty(&self, params: impl AsRef<Params>) -> u128
Computes the popular “difficulty” measure for mining.
Difficulty represents how difficult the current target makes it to find a block, relative to how difficult it would be at the highest possible target (highest target == lowest difficulty).
pub fn difficulty_float(&self) -> f64
pub fn difficulty_float(&self) -> f64
Computes the popular “difficulty” measure for mining and returns a float value of f64.
pub fn validate_pow(
&self,
required_target: Target,
) -> Result<BlockHash, ValidationError>
pub fn validate_pow( &self, required_target: Target, ) -> Result<BlockHash, ValidationError>
Checks that the proof-of-work for the block is valid, returning the block hash.
pub fn work(&self) -> Work
pub fn work(&self) -> Work
Returns the total work of the block.
Trait Implementations§
Source§impl Clone for DiskBlockHeader
impl Clone for DiskBlockHeader
Source§fn clone(&self) -> DiskBlockHeader
fn clone(&self) -> DiskBlockHeader
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more