mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-24 21:45:41 +00:00
client: helper to create standalone client without service (#4536)
This commit is contained in:
@@ -139,28 +139,32 @@ pub type TLightCallExecutor<TBl, TExecDisp> = sc_client::light::call_executor::G
|
|||||||
>,
|
>,
|
||||||
>;
|
>;
|
||||||
|
|
||||||
impl<TCfg, TGen, TCSExt> ServiceBuilder<(), (), TCfg, TGen, TCSExt, (), (), (), (), (), (), (), (), (), ()>
|
type TFullParts<TBl, TRtApi, TExecDisp> = (
|
||||||
where TGen: RuntimeGenesis, TCSExt: Extension {
|
|
||||||
/// Start the service builder with a configuration.
|
|
||||||
pub fn new_full<TBl: BlockT<Hash=H256>, TRtApi, TExecDisp: NativeExecutionDispatch>(
|
|
||||||
config: Configuration<TCfg, TGen, TCSExt>
|
|
||||||
) -> Result<ServiceBuilder<
|
|
||||||
TBl,
|
|
||||||
TRtApi,
|
|
||||||
TCfg,
|
|
||||||
TGen,
|
|
||||||
TCSExt,
|
|
||||||
TFullClient<TBl, TRtApi, TExecDisp>,
|
TFullClient<TBl, TRtApi, TExecDisp>,
|
||||||
Arc<OnDemand<TBl>>,
|
Arc<TFullBackend<TBl>>,
|
||||||
(),
|
Arc<RwLock<sc_keystore::Store>>,
|
||||||
(),
|
);
|
||||||
BoxFinalityProofRequestBuilder<TBl>,
|
|
||||||
Arc<dyn FinalityProofProvider<TBl>>,
|
/// Creates a new full client for the given config.
|
||||||
(),
|
pub fn new_full_client<TBl, TRtApi, TExecDisp, TCfg, TGen, TCSExt>(
|
||||||
(),
|
config: &Configuration<TCfg, TGen, TCSExt>,
|
||||||
(),
|
) -> Result<TFullClient<TBl, TRtApi, TExecDisp>, Error> where
|
||||||
TFullBackend<TBl>,
|
TBl: BlockT<Hash=H256>,
|
||||||
>, Error> {
|
TExecDisp: NativeExecutionDispatch,
|
||||||
|
TGen: sp_runtime::BuildStorage + serde::Serialize + for<'de> serde::Deserialize<'de>,
|
||||||
|
TCSExt: Extension,
|
||||||
|
{
|
||||||
|
new_full_parts(config).map(|parts| parts.0)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn new_full_parts<TBl, TRtApi, TExecDisp, TCfg, TGen, TCSExt>(
|
||||||
|
config: &Configuration<TCfg, TGen, TCSExt>,
|
||||||
|
) -> Result<TFullParts<TBl, TRtApi, TExecDisp>, Error> where
|
||||||
|
TBl: BlockT<Hash=H256>,
|
||||||
|
TExecDisp: NativeExecutionDispatch,
|
||||||
|
TGen: sp_runtime::BuildStorage + serde::Serialize + for<'de> serde::Deserialize<'de>,
|
||||||
|
TCSExt: Extension,
|
||||||
|
{
|
||||||
let keystore = Keystore::open(
|
let keystore = Keystore::open(
|
||||||
config.keystore_path.clone().ok_or("No basepath configured")?,
|
config.keystore_path.clone().ok_or("No basepath configured")?,
|
||||||
config.keystore_password.clone()
|
config.keystore_password.clone()
|
||||||
@@ -208,6 +212,33 @@ where TGen: RuntimeGenesis, TCSExt: Extension {
|
|||||||
)?
|
)?
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Ok((client, backend, keystore))
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<TCfg, TGen, TCSExt> ServiceBuilder<(), (), TCfg, TGen, TCSExt, (), (), (), (), (), (), (), (), (), ()>
|
||||||
|
where TGen: RuntimeGenesis, TCSExt: Extension {
|
||||||
|
/// Start the service builder with a configuration.
|
||||||
|
pub fn new_full<TBl: BlockT<Hash=H256>, TRtApi, TExecDisp: NativeExecutionDispatch>(
|
||||||
|
config: Configuration<TCfg, TGen, TCSExt>
|
||||||
|
) -> Result<ServiceBuilder<
|
||||||
|
TBl,
|
||||||
|
TRtApi,
|
||||||
|
TCfg,
|
||||||
|
TGen,
|
||||||
|
TCSExt,
|
||||||
|
TFullClient<TBl, TRtApi, TExecDisp>,
|
||||||
|
Arc<OnDemand<TBl>>,
|
||||||
|
(),
|
||||||
|
(),
|
||||||
|
BoxFinalityProofRequestBuilder<TBl>,
|
||||||
|
Arc<dyn FinalityProofProvider<TBl>>,
|
||||||
|
(),
|
||||||
|
(),
|
||||||
|
(),
|
||||||
|
TFullBackend<TBl>,
|
||||||
|
>, Error> {
|
||||||
|
let (client, backend, keystore) = new_full_parts(&config)?;
|
||||||
|
|
||||||
let client = Arc::new(client);
|
let client = Arc::new(client);
|
||||||
|
|
||||||
Ok(ServiceBuilder {
|
Ok(ServiceBuilder {
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ use sp_runtime::traits::{NumberFor, Block as BlockT};
|
|||||||
|
|
||||||
pub use self::error::Error;
|
pub use self::error::Error;
|
||||||
pub use self::builder::{
|
pub use self::builder::{
|
||||||
|
new_full_client,
|
||||||
ServiceBuilder, ServiceBuilderCommand, TFullClient, TLightClient, TFullBackend, TLightBackend,
|
ServiceBuilder, ServiceBuilderCommand, TFullClient, TLightClient, TFullBackend, TLightBackend,
|
||||||
TFullCallExecutor, TLightCallExecutor,
|
TFullCallExecutor, TLightCallExecutor,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user