feat: add helper function to modify node builder (#11682)

This commit is contained in:
Kien Trinh
2024-10-12 22:45:47 +07:00
committed by GitHub
parent 86c6ba5d8d
commit c47621754f

View File

@ -162,6 +162,14 @@ impl<ChainSpec> NodeBuilder<(), ChainSpec> {
pub const fn new(config: NodeConfig<ChainSpec>) -> Self {
Self { config, database: () }
}
/// Apply a function to the builder
pub fn apply<F>(self, f: F) -> Self
where
F: FnOnce(Self) -> Self,
{
f(self)
}
}
impl<DB, ChainSpec> NodeBuilder<DB, ChainSpec> {
@ -400,6 +408,14 @@ where
&self.builder.config
}
/// Apply a function to the builder
pub fn apply<F>(self, f: F) -> Self
where
F: FnOnce(Self) -> Self,
{
f(self)
}
/// Sets the hook that is run once the node's components are initialized.
pub fn on_component_initialized<F>(self, hook: F) -> Self
where