chore: extend consensus with fork choice state (#27)

* consensus fork choice

* fork_choice -> fork_choice_state
This commit is contained in:
Roman Krasiuk
2022-10-09 20:31:57 +03:00
committed by GitHub
parent 401cd3ec34
commit 573d343b66
3 changed files with 10 additions and 1 deletions

2
Cargo.lock generated
View File

@ -1450,7 +1450,9 @@ dependencies = [
"async-trait",
"auto_impl",
"reth-primitives",
"reth-rpc-types",
"thiserror",
"tokio",
]
[[package]]

View File

@ -8,6 +8,8 @@ readme = "README.md"
[dependencies]
reth-primitives = { path = "../primitives" }
reth-rpc-types = { path = "../net/rpc-types" }
async-trait = "0.1.57"
thiserror = "1.0.37"
auto_impl = "1.0"
auto_impl = "1.0"
tokio = { version = "1.21.2", features = ["sync"] }

View File

@ -1,11 +1,16 @@
use async_trait::async_trait;
use reth_primitives::Header;
use reth_rpc_types::engine::ForkchoiceState;
use thiserror::Error;
use tokio::sync::watch::Receiver;
/// Consensus is a protocol that chooses canonical chain.
/// We are checking validity of block header here.
#[async_trait]
pub trait Consensus {
/// Get a receiver for the fork choice state
fn fork_choice_state(&self) -> Receiver<ForkchoiceState>;
/// Validate if header is correct and follows consensus specification
fn validate_header(&self, _header: &Header) -> Result<(), Error> {
Ok(())