mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 22:51:13 +00:00
get rid of needless deps
This commit is contained in:
@@ -13,4 +13,3 @@ subxt = { path = "../subxt", version = "0.16.0" }
|
|||||||
sp-core = "4.0.0"
|
sp-core = "4.0.0"
|
||||||
async-std = { version = "1.9.0", features = ["attributes", "tokio1"] }
|
async-std = { version = "1.9.0", features = ["attributes", "tokio1"] }
|
||||||
which = "4.2.2"
|
which = "4.2.2"
|
||||||
jsonrpsee = { version = "0.8", features = ["http-client"] }
|
|
||||||
|
|||||||
+14
-9
@@ -14,10 +14,6 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with subxt. If not, see <http://www.gnu.org/licenses/>.
|
// along with subxt. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
use jsonrpsee::{
|
|
||||||
core::client::ClientT,
|
|
||||||
http_client::HttpClientBuilder,
|
|
||||||
};
|
|
||||||
use std::{
|
use std::{
|
||||||
env,
|
env,
|
||||||
fs,
|
fs,
|
||||||
@@ -35,6 +31,10 @@ use std::{
|
|||||||
thread,
|
thread,
|
||||||
time,
|
time,
|
||||||
};
|
};
|
||||||
|
use subxt::rpc::{
|
||||||
|
self,
|
||||||
|
ClientT,
|
||||||
|
};
|
||||||
|
|
||||||
static SUBSTRATE_BIN_ENV_VAR: &str = "SUBSTRATE_NODE_PATH";
|
static SUBSTRATE_BIN_ENV_VAR: &str = "SUBSTRATE_NODE_PATH";
|
||||||
|
|
||||||
@@ -54,7 +54,7 @@ async fn run() {
|
|||||||
let cmd = Command::new(&substrate_bin)
|
let cmd = Command::new(&substrate_bin)
|
||||||
.arg("--dev")
|
.arg("--dev")
|
||||||
.arg("--tmp")
|
.arg("--tmp")
|
||||||
.arg(format!("--rpc-port={}", port))
|
.arg(format!("--ws-port={}", port))
|
||||||
.spawn();
|
.spawn();
|
||||||
let mut cmd = match cmd {
|
let mut cmd = match cmd {
|
||||||
Ok(cmd) => KillOnDrop(cmd),
|
Ok(cmd) => KillOnDrop(cmd),
|
||||||
@@ -67,15 +67,20 @@ async fn run() {
|
|||||||
let metadata_bytes: sp_core::Bytes = {
|
let metadata_bytes: sp_core::Bytes = {
|
||||||
const MAX_RETRIES: usize = 20;
|
const MAX_RETRIES: usize = 20;
|
||||||
let mut retries = 0;
|
let mut retries = 0;
|
||||||
let rpc_client = HttpClientBuilder::default()
|
|
||||||
.build(&format!("http://localhost:{}", port))
|
|
||||||
.expect("valid URL; qed");
|
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
if retries >= MAX_RETRIES {
|
if retries >= MAX_RETRIES {
|
||||||
panic!("Cannot connect to substrate node after {} retries", retries);
|
panic!("Cannot connect to substrate node after {} retries", retries);
|
||||||
}
|
}
|
||||||
let res = rpc_client.request("state_getMetadata", None).await;
|
|
||||||
|
// It might take a while for substrate node that spin up the RPC server.
|
||||||
|
// Thus, the connection might get rejected a few times.
|
||||||
|
let res =
|
||||||
|
match rpc::build_ws_client(&format!("ws://localhost:{}", port)).await {
|
||||||
|
Ok(c) => c.request("state_getMetadata", None).await,
|
||||||
|
Err(e) => Err(e),
|
||||||
|
};
|
||||||
|
|
||||||
match res {
|
match res {
|
||||||
Ok(res) => {
|
Ok(res) => {
|
||||||
let _ = cmd.kill();
|
let _ = cmd.kill();
|
||||||
|
|||||||
Reference in New Issue
Block a user