mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
@ -10,7 +10,7 @@ use clap::{crate_version, Parser};
|
|||||||
use eyre::WrapErr;
|
use eyre::WrapErr;
|
||||||
use metrics_exporter_prometheus::PrometheusBuilder;
|
use metrics_exporter_prometheus::PrometheusBuilder;
|
||||||
use metrics_util::layers::{PrefixLayer, Stack};
|
use metrics_util::layers::{PrefixLayer, Stack};
|
||||||
use reth_consensus::EthConsensus;
|
use reth_consensus::BeaconConsensus;
|
||||||
use reth_db::{
|
use reth_db::{
|
||||||
cursor::DbCursorRO,
|
cursor::DbCursorRO,
|
||||||
database::Database,
|
database::Database,
|
||||||
@ -105,7 +105,7 @@ impl Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let chain_id = self.chain.consensus.chain_id;
|
let chain_id = self.chain.consensus.chain_id;
|
||||||
let consensus = Arc::new(EthConsensus::new(self.chain.consensus.clone()));
|
let consensus = Arc::new(BeaconConsensus::new(self.chain.consensus.clone()));
|
||||||
let genesis_hash = init_genesis(db.clone(), self.chain.genesis.clone())?;
|
let genesis_hash = init_genesis(db.clone(), self.chain.genesis.clone())?;
|
||||||
|
|
||||||
info!("Connecting to p2p");
|
info!("Connecting to p2p");
|
||||||
|
|||||||
@ -1,20 +1,22 @@
|
|||||||
//! Consensus for ethereum network
|
//! Consensus for ethereum network
|
||||||
|
|
||||||
use crate::{verification, Config};
|
use crate::{verification, Config};
|
||||||
use reth_interfaces::consensus::{Consensus, Error, ForkchoiceState};
|
use reth_interfaces::consensus::{Consensus, Error, ForkchoiceState};
|
||||||
use reth_primitives::{BlockLocked, BlockNumber, SealedHeader, H256};
|
use reth_primitives::{BlockLocked, BlockNumber, SealedHeader, H256};
|
||||||
use tokio::sync::{watch, watch::error::SendError};
|
use tokio::sync::{watch, watch::error::SendError};
|
||||||
|
|
||||||
/// Ethereum consensus
|
/// Ethereum beacon consensus
|
||||||
pub struct EthConsensus {
|
///
|
||||||
|
/// This consensus engine does basic checks as outlined in the execution specs,
|
||||||
|
/// but otherwise defers consensus on what the current chain is to a consensus client.
|
||||||
|
pub struct BeaconConsensus {
|
||||||
/// Watcher over the forkchoice state
|
/// Watcher over the forkchoice state
|
||||||
channel: (watch::Sender<ForkchoiceState>, watch::Receiver<ForkchoiceState>),
|
channel: (watch::Sender<ForkchoiceState>, watch::Receiver<ForkchoiceState>),
|
||||||
/// Configuration
|
/// Configuration
|
||||||
config: Config,
|
config: Config,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EthConsensus {
|
impl BeaconConsensus {
|
||||||
/// Create a new instance of [EthConsensus]
|
/// Create a new instance of [BeaconConsensus]
|
||||||
pub fn new(config: Config) -> Self {
|
pub fn new(config: Config) -> Self {
|
||||||
Self {
|
Self {
|
||||||
channel: watch::channel(ForkchoiceState {
|
channel: watch::channel(ForkchoiceState {
|
||||||
@ -35,7 +37,7 @@ impl EthConsensus {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Consensus for EthConsensus {
|
impl Consensus for BeaconConsensus {
|
||||||
fn fork_choice_state(&self) -> watch::Receiver<ForkchoiceState> {
|
fn fork_choice_state(&self) -> watch::Receiver<ForkchoiceState> {
|
||||||
self.channel.1.clone()
|
self.channel.1.clone()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,5 +14,5 @@ pub mod consensus;
|
|||||||
pub mod verification;
|
pub mod verification;
|
||||||
|
|
||||||
pub use config::Config;
|
pub use config::Config;
|
||||||
pub use consensus::EthConsensus;
|
pub use consensus::BeaconConsensus;
|
||||||
pub use reth_interfaces::consensus::Error;
|
pub use reth_interfaces::consensus::Error;
|
||||||
|
|||||||
Reference in New Issue
Block a user