Support custom fork choice rule (#1339)

* Support custom fork choice rule

* Remove unneeded reexport

* Fix network compile
This commit is contained in:
Wei Tang
2019-01-04 20:34:58 +01:00
committed by Robert Habermeier
parent 771a8127c2
commit ac1be0665e
6 changed files with 28 additions and 6 deletions
@@ -53,6 +53,15 @@ pub enum BlockOrigin {
File,
}
/// Fork choice strategy.
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum ForkChoiceStrategy {
/// Longest chain fork choice.
LongestChain,
/// Custom fork choice rule, where true indicates the new block should be the best block.
Custom(bool),
}
/// Data required to import a Block
pub struct ImportBlock<Block: BlockT> {
/// Origin of the Block
@@ -83,6 +92,8 @@ pub struct ImportBlock<Block: BlockT> {
/// Contains a list of key-value pairs. If values are `None`, the keys
/// will be deleted.
pub auxiliary: Vec<(Vec<u8>, Option<Vec<u8>>)>,
/// Fork choice strategy of this import.
pub fork_choice: ForkChoiceStrategy,
}
impl<Block: BlockT> ImportBlock<Block> {
+1 -1
View File
@@ -55,7 +55,7 @@ pub mod evaluation;
const MAX_TRANSACTIONS_SIZE: usize = 4 * 1024 * 1024;
pub use self::error::{Error, ErrorKind};
pub use block_import::{BlockImport, ImportBlock, BlockOrigin, ImportResult};
pub use block_import::{BlockImport, ImportBlock, BlockOrigin, ImportResult, ForkChoiceStrategy};
/// Trait for getting the authorities at a given block.
pub trait Authorities<B: Block> {