Struct chain_impl_mockchain::header::builder::HeaderBuilder
source · pub struct HeaderBuilder<HeaderBuildingState: ?Sized>(Header, PhantomData<HeaderBuildingState>);
Expand description
Finalized BFT Header
Tuple Fields§
§0: Header
§1: PhantomData<HeaderBuildingState>
Implementations§
source§impl HeaderBuilder<HeaderSetParenting>
impl HeaderBuilder<HeaderSetParenting>
sourcepub fn new(version: BlockVersion, contents: &Contents) -> Self
pub fn new(version: BlockVersion, contents: &Contents) -> Self
Create a new Header builder starting from the full content.
This doesn’t need the content directly, but only uses the content to calculate the content hash and the content size, and make sure this is consistent
sourcepub fn new_raw(
version: BlockVersion,
content_hash: &BlockContentHash,
content_size: BlockContentSize
) -> Self
pub fn new_raw( version: BlockVersion, content_hash: &BlockContentHash, content_size: BlockContentSize ) -> Self
recommended to use new(), this is only for test
source§impl HeaderBuilder<HeaderSetParenting>
impl HeaderBuilder<HeaderSetParenting>
sourcepub fn set_genesis(self) -> HeaderBuilder<HeaderSetDate>
pub fn set_genesis(self) -> HeaderBuilder<HeaderSetDate>
Set the header as a genesis header:
- the depth starts at 0
- the parent is set to the “null hash” (hash all 0)
sourcepub fn set_parent(
self,
parent_hash: &HeaderId,
chain_length: ChainLength
) -> HeaderBuilder<HeaderSetDate>
pub fn set_parent( self, parent_hash: &HeaderId, chain_length: ChainLength ) -> HeaderBuilder<HeaderSetDate>
Set the header as a general block, with a specific depth and parent hash
source§impl HeaderBuilder<HeaderSetDate>
impl HeaderBuilder<HeaderSetDate>
sourcepub fn set_date(self, date: BlockDate) -> HeaderBuilder<HeaderCommonDone>
pub fn set_date(self, date: BlockDate) -> HeaderBuilder<HeaderCommonDone>
Set the date of this block
source§impl HeaderBuilder<HeaderCommonDone>
impl HeaderBuilder<HeaderCommonDone>
sourcepub fn into_unsigned_header(self) -> Option<HeaderUnsigned>
pub fn into_unsigned_header(self) -> Option<HeaderUnsigned>
Finalized to an unsigned header
sourcepub fn into_bft_builder(
self
) -> Option<HeaderBftBuilder<HeaderSetConsensusData>>
pub fn into_bft_builder( self ) -> Option<HeaderBftBuilder<HeaderSetConsensusData>>
Tentatively transition to a BFT Header builder
sourcepub fn into_genesis_praos_builder(
self
) -> Option<HeaderGenesisPraosBuilder<HeaderSetConsensusData>>
pub fn into_genesis_praos_builder( self ) -> Option<HeaderGenesisPraosBuilder<HeaderSetConsensusData>>
Tentatively transition to a Genesis-Praos Header builder
Auto Trait Implementations§
impl<HeaderBuildingState: ?Sized> RefUnwindSafe for HeaderBuilder<HeaderBuildingState>where HeaderBuildingState: RefUnwindSafe,
impl<HeaderBuildingState: ?Sized> Send for HeaderBuilder<HeaderBuildingState>where HeaderBuildingState: Send,
impl<HeaderBuildingState: ?Sized> Sync for HeaderBuilder<HeaderBuildingState>where HeaderBuildingState: Sync,
impl<HeaderBuildingState: ?Sized> Unpin for HeaderBuilder<HeaderBuildingState>where HeaderBuildingState: Unpin,
impl<HeaderBuildingState: ?Sized> UnwindSafe for HeaderBuilder<HeaderBuildingState>where HeaderBuildingState: UnwindSafe,
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
Mutably borrows from an owned value. Read more