[][src]Trait sc_consensus_pow::PowAlgorithm

pub trait PowAlgorithm<B: BlockT> {
    type Difficulty: TotalDifficulty + Default + Encode + Decode + Ord + Clone + Copy;
    fn difficulty(
        &self,
        parent: &BlockId<B>
    ) -> Result<Self::Difficulty, Error<B>>;
fn verify(
        &self,
        parent: &BlockId<B>,
        pre_hash: &B::Hash,
        seal: &Seal,
        difficulty: Self::Difficulty
    ) -> Result<bool, Error<B>>;
fn mine(
        &self,
        parent: &BlockId<B>,
        pre_hash: &B::Hash,
        difficulty: Self::Difficulty,
        round: u32
    ) -> Result<Option<Seal>, Error<B>>; fn preliminary_verify(
        &self,
        _pre_hash: &B::Hash,
        _seal: &Seal
    ) -> Result<Option<bool>, Error<B>> { ... } }

Algorithm used for proof of work.

Associated Types

type Difficulty: TotalDifficulty + Default + Encode + Decode + Ord + Clone + Copy

Difficulty for the algorithm.

Loading content...

Required methods

fn difficulty(&self, parent: &BlockId<B>) -> Result<Self::Difficulty, Error<B>>

Get the next block's difficulty.

This function will be called twice during the import process, so the implementation should be properly cached.

fn verify(
    &self,
    parent: &BlockId<B>,
    pre_hash: &B::Hash,
    seal: &Seal,
    difficulty: Self::Difficulty
) -> Result<bool, Error<B>>

Verify that the difficulty is valid against given seal.

fn mine(
    &self,
    parent: &BlockId<B>,
    pre_hash: &B::Hash,
    difficulty: Self::Difficulty,
    round: u32
) -> Result<Option<Seal>, Error<B>>

Mine a seal that satisfies the given difficulty.

Loading content...

Provided methods

fn preliminary_verify(
    &self,
    _pre_hash: &B::Hash,
    _seal: &Seal
) -> Result<Option<bool>, Error<B>>

Verify that the seal is valid against given pre hash when parent block is not yet imported.

None means that preliminary verify is not available for this algorithm.

Loading content...

Implementors

Loading content...