mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 04:41:02 +00:00
+6
-6
@@ -12,19 +12,19 @@ description = "Embed a substrate node into your subxt application."
|
||||
keywords = ["parity", "substrate", "blockchain"]
|
||||
|
||||
[dependencies]
|
||||
async-std = "1.6.2"
|
||||
async-std = "1.6.3"
|
||||
futures = { version = "0.3.5", features = ["compat"] }
|
||||
futures01 = { package = "futures", version = "0.1.29" }
|
||||
jsonrpsee = "0.1.0"
|
||||
log = "0.4.11"
|
||||
sc-network = { version = "0.8.0-rc5", default-features = false }
|
||||
sc-service = { version = "0.8.0-rc5", default-features = false }
|
||||
serde_json = "1.0.56"
|
||||
sp-keyring = "2.0.0-rc5"
|
||||
sc-network = { version = "0.8.0-rc6", default-features = false }
|
||||
sc-service = { version = "0.8.0-rc6", default-features = false }
|
||||
serde_json = "1.0.57"
|
||||
sp-keyring = "2.0.0-rc6"
|
||||
thiserror = "1.0.20"
|
||||
|
||||
[dev-dependencies]
|
||||
async-std = { version = "1.6.2", features = ["attributes"] }
|
||||
async-std = { version = "1.6.3", features = ["attributes"] }
|
||||
env_logger = "0.7.1"
|
||||
substrate-subxt = { path = ".." }
|
||||
tempdir = "0.3.7"
|
||||
|
||||
+5
-9
@@ -64,7 +64,6 @@ use sc_service::{
|
||||
use std::{
|
||||
future::Future,
|
||||
pin::Pin,
|
||||
sync::Arc,
|
||||
};
|
||||
use thiserror::Error;
|
||||
|
||||
@@ -87,17 +86,16 @@ pub struct SubxtClient {
|
||||
|
||||
impl SubxtClient {
|
||||
/// Create a new client.
|
||||
pub fn new(mut task_manager: TaskManager, rpc: Arc<RpcHandlers>) -> Self {
|
||||
pub fn new(mut task_manager: TaskManager, rpc: RpcHandlers) -> Self {
|
||||
let (to_back, from_front) = mpsc::channel(4);
|
||||
let (to_front, from_back) = mpsc01::channel(4);
|
||||
|
||||
let session = RpcSession::new(to_front.clone());
|
||||
let session2 = session.clone();
|
||||
task::spawn(
|
||||
select(
|
||||
Box::pin(from_front.for_each(move |message: String| {
|
||||
let rpc = rpc.clone();
|
||||
let session = session2.clone();
|
||||
let session = session.clone();
|
||||
let mut to_front = to_front.clone().sink_compat();
|
||||
async move {
|
||||
let response = rpc.rpc_query(&session, &message).await;
|
||||
@@ -122,11 +120,9 @@ impl SubxtClient {
|
||||
/// Creates a new client from a config.
|
||||
pub fn from_config<C: ChainSpec + 'static>(
|
||||
config: SubxtClientConfig<C>,
|
||||
builder: impl Fn(
|
||||
Configuration,
|
||||
) -> Result<(TaskManager, Arc<RpcHandlers>), ServiceError>,
|
||||
builder: impl Fn(Configuration) -> Result<(TaskManager, RpcHandlers), ServiceError>,
|
||||
) -> Result<Self, ServiceError> {
|
||||
let config = config.to_service_config();
|
||||
let config = config.into_service_config();
|
||||
let (task_manager, rpc_handlers) = (builder)(config)?;
|
||||
Ok(Self::new(task_manager, rpc_handlers))
|
||||
}
|
||||
@@ -224,7 +220,7 @@ pub struct SubxtClientConfig<C: ChainSpec + 'static> {
|
||||
|
||||
impl<C: ChainSpec + 'static> SubxtClientConfig<C> {
|
||||
/// Creates a service configuration.
|
||||
pub fn to_service_config(self) -> Configuration {
|
||||
pub fn into_service_config(self) -> Configuration {
|
||||
let mut network = NetworkConfiguration::new(
|
||||
format!("{} (subxt client)", self.chain_spec.name()),
|
||||
"unknown",
|
||||
|
||||
Reference in New Issue
Block a user