Repository navigation
Expand file tree
/
Copy pathengine.rs
More file actions
62 lines (55 loc) · 1.75 KB
/
Copy pathengine.rs
File metadata and controls
62 lines (55 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//! Consensus component for the node builder.
use reth_node_api::{EngineValidator, NodeTypesWithEngine};
use crate::{BuilderContext, FullNodeTypes};
use reth_bsc_consensus::Parlia;
use std::future::Future;
/// A type that knows how to build the engine validator.
pub trait EngineValidatorBuilder<Node: FullNodeTypes>: Send {
/// The consensus implementation to build.
type Validator: EngineValidator<<Node::Types as NodeTypesWithEngine>::Engine>
+ Clone
+ Unpin
+ 'static;
/// Creates the engine validator.
fn build_validator(
self,
ctx: &BuilderContext<Node>,
) -> impl Future<Output = eyre::Result<Self::Validator>> + Send;
}
impl<Node, F, Fut, Validator> EngineValidatorBuilder<Node> for F
where
Node: FullNodeTypes,
Validator:
EngineValidator<<Node::Types as NodeTypesWithEngine>::Engine> + Clone + Unpin + 'static,
F: FnOnce(&BuilderContext<Node>) -> Fut + Send,
Fut: Future<Output = eyre::Result<Validator>> + Send,
{
type Validator = Validator;
fn build_validator(
self,
ctx: &BuilderContext<Node>,
) -> impl Future<Output = eyre::Result<Self::Validator>> {
self(ctx)
}
}
/// Needed for bsc parlia consensus.
pub trait ParliaBuilder<Node: FullNodeTypes>: Send {
/// Creates the parlia.
fn build_parlia(
self,
ctx: &BuilderContext<Node>,
) -> impl Future<Output = eyre::Result<Parlia>> + Send;
}
impl<Node, F, Fut> ParliaBuilder<Node> for F
where
Node: FullNodeTypes,
F: FnOnce(&BuilderContext<Node>) -> Fut + Send,
Fut: Future<Output = eyre::Result<Parlia>> + Send,
{
fn build_parlia(
self,
ctx: &BuilderContext<Node>,
) -> impl Future<Output = eyre::Result<Parlia>> {
self(ctx)
}
}