mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 19:17:58 +00:00
Make run_node_until_exit take a future (#7318)
The function takes a closure that resolved before to a `TaskManager`, now it resolves to a `Future` which output is a `TaskManager`. This is required for node setups that are async.
This commit is contained in:
@@ -172,24 +172,24 @@ impl<C: SubstrateCli> Runner<C> {
|
||||
|
||||
/// A helper function that runs a node with tokio and stops if the process receives the signal
|
||||
/// `SIGTERM` or `SIGINT`.
|
||||
pub fn run_node_until_exit(
|
||||
pub fn run_node_until_exit<F: Future<Output = sc_service::error::Result<TaskManager>>>(
|
||||
mut self,
|
||||
initialise: impl FnOnce(Configuration) -> sc_service::error::Result<TaskManager>,
|
||||
initialize: impl FnOnce(Configuration) -> F,
|
||||
) -> Result<()> {
|
||||
self.print_node_infos();
|
||||
let mut task_manager = initialise(self.config)?;
|
||||
let mut task_manager = self.tokio_runtime.block_on(initialize(self.config))?;
|
||||
let res = self.tokio_runtime.block_on(main(task_manager.future().fuse()));
|
||||
self.tokio_runtime.block_on(task_manager.clean_shutdown());
|
||||
res.map_err(|e| e.to_string().into())
|
||||
}
|
||||
|
||||
/// A helper function that runs a command with the configuration of this node
|
||||
/// A helper function that runs a command with the configuration of this node.
|
||||
pub fn sync_run(self, runner: impl FnOnce(Configuration) -> Result<()>) -> Result<()> {
|
||||
runner(self.config)
|
||||
}
|
||||
|
||||
/// A helper function that runs a future with tokio and stops if the process receives
|
||||
/// the signal SIGTERM or SIGINT
|
||||
/// the signal `SIGTERM` or `SIGINT`.
|
||||
pub fn async_run<FUT>(
|
||||
self, runner: impl FnOnce(Configuration) -> Result<(FUT, TaskManager)>,
|
||||
) -> Result<()>
|
||||
|
||||
Reference in New Issue
Block a user