diff --git a/core/cli/src/commands/dev.rs b/core/cli/src/commands/dev.rs index 6b7e9e1df..fe1226d48 100644 --- a/core/cli/src/commands/dev.rs +++ b/core/cli/src/commands/dev.rs @@ -2,7 +2,7 @@ use std::path::PathBuf; use anyhow::{Context, Result}; use lightning_interfaces::prelude::*; -use lightning_rpc::api::AdminApiClient; +use lightning_rpc::interface::Admin; use lightning_utils::config::TomlConfigProvider; use resolved_pathbuf::ResolvedPathBuf; @@ -42,7 +42,7 @@ where for path in &input { if let Some(path) = path.to_str() { - let response = AdminApiClient::store(&client, path.to_string()).await?; + let response = Admin::store(&client, path.to_string()).await?; println!("{:x}\t{path:?}", ByteBuf(&response)); } else { diff --git a/core/cli/src/commands/opt.rs b/core/cli/src/commands/opt.rs index 4e507d1b6..60b0c454c 100644 --- a/core/cli/src/commands/opt.rs +++ b/core/cli/src/commands/opt.rs @@ -21,6 +21,7 @@ use lightning_interfaces::types::{ UpdateRequest, }; use lightning_rpc::api::RpcClient; +use lightning_rpc::interface::Fleek; use lightning_utils::config::TomlConfigProvider; use resolved_pathbuf::ResolvedPathBuf; @@ -272,11 +273,9 @@ pub async fn send_txn(update_request: UpdateRequest, nodes: &[NodeInfo]) -> Resu let client = RpcClient::new_no_auth(&rpc_address)?; - Ok( - lightning_rpc::Fleek::send_txn(&client, update_request.into()) - .await - .map(|_| ())?, - ) + Ok(Fleek::send_txn(&client, update_request.into()) + .await + .map(|_| ())?) } pub async fn get_node_info_from_genesis_commitee( @@ -294,9 +293,7 @@ pub async fn get_node_info_from_genesis_commitee( .ok()?; Some(( - lightning_rpc::Fleek::get_node_info_epoch(&client, public_key) - .await - .ok()?, + Fleek::get_node_info_epoch(&client, public_key).await.ok()?, address, )) }; @@ -329,10 +326,7 @@ pub async fn get_epoch_info_from_genesis_commitee( }) .ok()?; - Some(( - lightning_rpc::Fleek::get_epoch_info(&client).await.ok()?, - address, - )) + Some((Fleek::get_epoch_info(&client).await.ok()?, address)) }; futs.push(fut); } diff --git a/core/e2e/tests/checkpoint.rs b/core/e2e/tests/checkpoint.rs index c93de26ac..dd9e4a58b 100644 --- a/core/e2e/tests/checkpoint.rs +++ b/core/e2e/tests/checkpoint.rs @@ -3,7 +3,8 @@ use std::time::{Duration, SystemTime}; use anyhow::Result; use lightning_e2e::swarm::Swarm; -use lightning_rpc::{Fleek, RpcClient}; +use lightning_rpc::interface::Fleek; +use lightning_rpc::RpcClient; use lightning_test_utils::config::LIGHTNING_TEST_HOME_DIR; use lightning_test_utils::logging; use resolved_pathbuf::ResolvedPathBuf; diff --git a/core/e2e/tests/epoch_change.rs b/core/e2e/tests/epoch_change.rs index adaa33a91..be6879724 100644 --- a/core/e2e/tests/epoch_change.rs +++ b/core/e2e/tests/epoch_change.rs @@ -7,7 +7,8 @@ use fleek_crypto::NodePublicKey; use hp_fixed::unsigned::HpUfixed; use lightning_e2e::swarm::{Swarm, SwarmNode}; use lightning_interfaces::types::Staking; -use lightning_rpc::{Fleek, RpcClient}; +use lightning_rpc::interface::Fleek; +use lightning_rpc::RpcClient; use lightning_test_utils::config::LIGHTNING_TEST_HOME_DIR; use lightning_test_utils::logging; use resolved_pathbuf::ResolvedPathBuf; @@ -241,7 +242,7 @@ async fn e2e_test_staking_auction() -> Result<()> { // Wait for epoch to change. tokio::time::sleep(Duration::from_secs(30)).await; - let client = RpcClient::new_no_auth(&rpc_endpoint.1)?; + let client = RpcClient::new_no_auth(rpc_endpoint.1)?; let response = client.get_committee_members(None).await?; let current_committee: BTreeSet = response.into_iter().collect(); @@ -249,12 +250,8 @@ async fn e2e_test_staking_auction() -> Result<()> { .iter() .for_each(|node| println!("{:?}", node)); - let rep_one = client - .get_reputation(low_stake_nodes[0].clone(), None) - .await?; - let rep_two = client - .get_reputation(low_stake_nodes[1].clone(), None) - .await?; + let rep_one = client.get_reputation(*low_stake_nodes[0], None).await?; + let rep_two = client.get_reputation(*low_stake_nodes[1], None).await?; // Make sure the lower reputation node lost the tiebreaker and is not on the active node list if rep_one <= rep_two { @@ -288,7 +285,7 @@ async fn compare_committee( if &rpc_addresses[0].1 == address { continue; } - let client = RpcClient::new_no_auth(&address).unwrap(); + let client = RpcClient::new_no_auth(address).unwrap(); let committee: BTreeSet<_> = client .get_committee_members(None) diff --git a/core/e2e/tests/pinger.rs b/core/e2e/tests/pinger.rs index 7ade42a82..76ee8c7bb 100644 --- a/core/e2e/tests/pinger.rs +++ b/core/e2e/tests/pinger.rs @@ -5,7 +5,7 @@ use anyhow::Result; use lightning_e2e::swarm::Swarm; use lightning_interfaces::types::Participation; use lightning_rpc::api::RpcClient; -use lightning_rpc::Fleek; +use lightning_rpc::interface::Fleek; use lightning_test_utils::config::LIGHTNING_TEST_HOME_DIR; use lightning_test_utils::logging; use resolved_pathbuf::ResolvedPathBuf; diff --git a/core/e2e/tests/syncronizer.rs b/core/e2e/tests/syncronizer.rs index 8354defd3..780c90241 100644 --- a/core/e2e/tests/syncronizer.rs +++ b/core/e2e/tests/syncronizer.rs @@ -6,7 +6,7 @@ use fleek_blake3 as blake3; use lightning_e2e::swarm::Swarm; use lightning_interfaces::prelude::*; use lightning_rpc::api::RpcClient; -use lightning_rpc::Fleek; +use lightning_rpc::interface::Fleek; use lightning_test_utils::config::LIGHTNING_TEST_HOME_DIR; use lightning_test_utils::logging; use resolved_pathbuf::ResolvedPathBuf; diff --git a/core/rpc/src/client.rs b/core/rpc/src/client.rs index 873063499..8e9719cbe 100644 --- a/core/rpc/src/client.rs +++ b/core/rpc/src/client.rs @@ -23,6 +23,7 @@ pub fn make_plain_rpc_client(address: &str) -> anyhow::Result), diff --git a/core/rpc/src/lib.rs b/core/rpc/src/lib.rs index 589b44454..c17d3acea 100644 --- a/core/rpc/src/lib.rs +++ b/core/rpc/src/lib.rs @@ -25,13 +25,16 @@ pub use crate::logic::{EthApi, FleekApi, NetApi}; pub mod client; pub mod api; -pub use api::{ - make_plain_rpc_client, - AdminApiClient as Admin, - EthApiClient as Eth, - FleekApiClient as Fleek, - NetApiClient as Net, -}; +pub mod interface { + pub use super::api::{ + make_plain_rpc_client, + AdminApiClient as Admin, + EthApiClient as Eth, + FleekApiClient as Fleek, + NetApiClient as Net, + }; +} + pub use client::{HmacClient, RpcClient}; pub type JsonRpcClient = diff --git a/core/syncronizer/src/rpc.rs b/core/syncronizer/src/rpc.rs index 7c6517102..108caf35a 100644 --- a/core/syncronizer/src/rpc.rs +++ b/core/syncronizer/src/rpc.rs @@ -5,7 +5,8 @@ use fleek_crypto::NodePublicKey; use futures::stream::FuturesOrdered; use futures::StreamExt; use lightning_interfaces::types::{Epoch, EpochInfo, NodeIndex, NodeInfo}; -use lightning_rpc::{Fleek, RpcClient}; +use lightning_rpc::interface::Fleek; +use lightning_rpc::RpcClient; use tokio::runtime::Handle; /// Runs the given future to completion on the current tokio runtime.