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 moreSource§impl Debug for DiskBlockHeader
impl Debug for DiskBlockHeader
Source§impl Decodable for DiskBlockHeader
Decodable is a trait from bitcoin::consensus::encode that allows decoding of a type from a reader in a consistent manner.
impl Decodable for DiskBlockHeader
Decodable is a trait from bitcoin::consensus::encode that allows decoding of a type from a reader in a consistent manner.
Source§impl Deref for DiskBlockHeader
DiskBlockHeader dereferences to the inner header type.
impl Deref for DiskBlockHeader
DiskBlockHeader dereferences to the inner header type.
Source§impl Encodable for DiskBlockHeader
impl Encodable for DiskBlockHeader
Source§impl PartialEq for DiskBlockHeader
impl PartialEq for DiskBlockHeader
impl Copy for DiskBlockHeader
impl StructuralPartialEq for DiskBlockHeader
Auto Trait Implementations§
impl Freeze for DiskBlockHeader
impl RefUnwindSafe for DiskBlockHeader
impl Send for DiskBlockHeader
impl Sync for DiskBlockHeader
impl Unpin for DiskBlockHeader
impl UnwindSafe for DiskBlockHeader
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more