mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
fix(net): set status, forkfilter from chainspec (#939)
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
use crate::{EthVersion, StatusBuilder};
|
||||
use crate::{BlockHashNumber, EthVersion, StatusBuilder};
|
||||
|
||||
use ethers_core::utils::Genesis;
|
||||
use reth_codecs::derive_arbitrary;
|
||||
@ -82,6 +82,23 @@ impl Status {
|
||||
pub fn builder() -> StatusBuilder {
|
||||
Default::default()
|
||||
}
|
||||
|
||||
/// Create a [`StatusBuilder`] from the given [`ChainSpec`](reth_primitives::ChainSpec) and
|
||||
/// head block number.
|
||||
///
|
||||
/// Sets the `chain` and `genesis`, `blockhash`, and `forkid` fields based on the [`ChainSpec`]
|
||||
/// and head.
|
||||
///
|
||||
/// The user should set the `total_difficulty` field if desired. Otherwise, the total
|
||||
/// difficulty will be set to the [`Default`](std::default::Default) implementation for
|
||||
/// [`Status`].
|
||||
pub fn spec_builder(spec: &ChainSpec, head: &BlockHashNumber) -> StatusBuilder {
|
||||
Self::builder()
|
||||
.chain(spec.chain)
|
||||
.genesis(spec.genesis_hash())
|
||||
.blockhash(head.hash)
|
||||
.forkid(spec.fork_id(head.number))
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for Status {
|
||||
|
||||
Reference in New Issue
Block a user