mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-18 08:21:03 +00:00
Preparing light client structure [v2] (#150)
* light client structure + remote call requests
This commit is contained in:
committed by
GitHub
parent
ab7eae6f88
commit
fa642cf01a
+28
-15
@@ -107,16 +107,7 @@ pub fn run<I, T>(args: I) -> error::Result<()> where
|
||||
I: IntoIterator<Item = T>,
|
||||
T: Into<std::ffi::OsString> + Clone,
|
||||
{
|
||||
let mut core = reactor::Core::new().expect("tokio::Core could not be created");
|
||||
let exit = {
|
||||
// can't use signal directly here because CtrlC takes only `Fn`.
|
||||
let (exit_send, exit) = mpsc::channel(1);
|
||||
ctrlc::CtrlC::set_handler(move || {
|
||||
exit_send.clone().send(()).wait().expect("Error sending exit notification");
|
||||
});
|
||||
|
||||
exit
|
||||
};
|
||||
let core = reactor::Core::new().expect("tokio::Core could not be created");
|
||||
|
||||
let yaml = load_yaml!("./cli.yml");
|
||||
let matches = match clap::App::from_yaml(yaml).version(crate_version!()).get_matches_from_safe(args) {
|
||||
@@ -152,10 +143,12 @@ pub fn run<I, T>(args: I) -> error::Result<()> where
|
||||
if matches.is_present("collator") {
|
||||
info!("Starting collator.");
|
||||
role = service::Role::COLLATOR;
|
||||
}
|
||||
else if matches.is_present("validator") {
|
||||
} else if matches.is_present("validator") {
|
||||
info!("Starting validator.");
|
||||
role = service::Role::VALIDATOR;
|
||||
} else if matches.is_present("light") {
|
||||
info!("Starting light.");
|
||||
role = service::Role::LIGHT;
|
||||
}
|
||||
|
||||
match matches.value_of("chain") {
|
||||
@@ -195,13 +188,33 @@ pub fn run<I, T>(args: I) -> error::Result<()> where
|
||||
|
||||
config.keys = matches.values_of("key").unwrap_or_default().map(str::to_owned).collect();
|
||||
|
||||
let service = service::Service::new(config)?;
|
||||
match role == service::Role::LIGHT {
|
||||
true => run_until_exit(core, service::new_light(config)?, &matches),
|
||||
false => run_until_exit(core, service::new_full(config)?, &matches),
|
||||
}
|
||||
}
|
||||
|
||||
fn run_until_exit<B, E>(mut core: reactor::Core, service: service::Service<B, E>, matches: &clap::ArgMatches) -> error::Result<()>
|
||||
where
|
||||
B: client::backend::Backend + Send + Sync + 'static,
|
||||
E: client::CallExecutor + Send + Sync + 'static,
|
||||
client::error::Error: From<<<B as client::backend::Backend>::State as state_machine::backend::Backend>::Error>
|
||||
{
|
||||
let exit = {
|
||||
// can't use signal directly here because CtrlC takes only `Fn`.
|
||||
let (exit_send, exit) = mpsc::channel(1);
|
||||
ctrlc::CtrlC::set_handler(move || {
|
||||
exit_send.clone().send(()).wait().expect("Error sending exit notification");
|
||||
});
|
||||
|
||||
exit
|
||||
};
|
||||
|
||||
informant::start(&service, core.handle());
|
||||
|
||||
let _rpc_servers = {
|
||||
let http_address = parse_address("127.0.0.1:9933", "rpc-port", &matches)?;
|
||||
let ws_address = parse_address("127.0.0.1:9944", "ws-port", &matches)?;
|
||||
let http_address = parse_address("127.0.0.1:9933", "rpc-port", matches)?;
|
||||
let ws_address = parse_address("127.0.0.1:9944", "ws-port", matches)?;
|
||||
|
||||
let handler = || {
|
||||
let chain = rpc::apis::chain::Chain::new(service.client(), core.remote());
|
||||
|
||||
Reference in New Issue
Block a user