mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-29 23:07:57 +00:00
Consensus: Proof of Work (#3473)
* consensus-pow: init primtives and verifier * consensus-pow: add total difficulty auxiliary * consensus-pow: implement total difficulty chain selection * consensus-pow: implement pow import queue * consensus-pow-primitives: add mine into PowApi * consensus-pow: implement mining * Update lock file * Style fixes No run-on expressions allowed. * consensus-pow: refactor register_pow_inherent_data_provider * consensus-pow: make PowApi::mine yieldable * consensus-pow: better mining loop * Add missing license header * consensus-pow-primitives: clarify the meaning of None for PowApi::verify * consensus-pow: changing total difficulty addition to use saturating add * consensus-pow: change mine-loop error to log on error! level * consensus-pow: allow inserting arbitrary preruntime digest for pow The preruntime digest can be intepreted by the runtime as the block author/coinbase. * Fix line width * More line width fixes * consensus-pow: separate difficulty, verify API This makes it more apparent that currently in PoW engine, `difficulty` should be input, not output. * srml-pow: implementation of average_span difficulty adjustment * srml-pow: basic blake2 algo example * srml-pow-average-span: make it not require genesis config * srml-pow: add support for authorship * Missing license headers * consensus-pow: PowAlgorithm trait generalization * Missing docs for consensus-pow * More docs * node-runtime: bump impl_version * Add rationale for difficulty type * consensus-pow: refactor aux_key * Update lock file * Update core/consensus/pow/src/lib.rs Co-Authored-By: Sergei Pepyakin <sergei@parity.io> * Update core/consensus/pow/src/lib.rs Co-Authored-By: Sergei Pepyakin <sergei@parity.io> * Update core/consensus/pow/src/lib.rs Co-Authored-By: Sergei Pepyakin <sergei@parity.io> * Update core/consensus/pow/src/lib.rs Co-Authored-By: Sergei Pepyakin <sergei@parity.io> * Update core/consensus/pow/src/lib.rs Co-Authored-By: Sergei Pepyakin <sergei@parity.io> * Update core/consensus/pow/src/lib.rs Co-Authored-By: Sergei Pepyakin <sergei@parity.io> * Update core/consensus/pow/src/lib.rs Co-Authored-By: Sergei Pepyakin <sergei@parity.io> * Update core/consensus/pow/primitives/src/lib.rs Co-Authored-By: Sergei Pepyakin <sergei@parity.io> * Update core/consensus/pow/primitives/src/lib.rs Co-Authored-By: Sergei Pepyakin <sergei@parity.io> * Remove PowRuntimeAlgorithm * block_id -> parent_block_id * Auxiliary data -> auxiliary storage data * Fix error message * Fix compile * Update core/consensus/pow/primitives/src/lib.rs Co-Authored-By: DemiMarie-parity <48690212+DemiMarie-parity@users.noreply.github.com> * Update core/consensus/pow/src/lib.rs Co-Authored-By: DemiMarie-parity <48690212+DemiMarie-parity@users.noreply.github.com> * Update core/consensus/pow/primitives/src/lib.rs Co-Authored-By: DemiMarie-parity <48690212+DemiMarie-parity@users.noreply.github.com> * Update core/consensus/pow/src/lib.rs Co-Authored-By: DemiMarie-parity <48690212+DemiMarie-parity@users.noreply.github.com> * Fix crate description * More docs * Address grumbles 1. Make preruntime Optional. 2. Add more docs on what is `preruntie` and `round`. 3. Replace `Default::default` with the approriate type.
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
// Copyright 2017-2019 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Substrate is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Substrate is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Primitives for Substrate Proof-of-Work (PoW) consensus.
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
use rstd::vec::Vec;
|
||||
use sr_primitives::ConsensusEngineId;
|
||||
|
||||
/// The `ConsensusEngineId` of PoW.
|
||||
pub const POW_ENGINE_ID: ConsensusEngineId = [b'p', b'o', b'w', b'_'];
|
||||
|
||||
/// Type of difficulty.
|
||||
///
|
||||
/// For runtime designed for Substrate, it's always possible to fit its total
|
||||
/// difficulty range under `u128::max_value()` because it can be freely scaled
|
||||
/// up or scaled down. Very few PoW chains use difficulty values
|
||||
/// larger than `u128::max_value()`.
|
||||
pub type Difficulty = u128;
|
||||
|
||||
/// Type of seal.
|
||||
pub type Seal = Vec<u8>;
|
||||
Reference in New Issue
Block a user