Skip to content

Commit

Permalink
fix: mod interface
Browse files Browse the repository at this point in the history
  • Loading branch information
nhtyy committed Jun 26, 2024
1 parent 34cf2c6 commit f03720a
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 34 deletions.
4 changes: 2 additions & 2 deletions core/cli/src/commands/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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 {
Expand Down
18 changes: 6 additions & 12 deletions core/cli/src/commands/opt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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(
Expand All @@ -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,
))
};
Expand Down Expand Up @@ -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);
}
Expand Down
3 changes: 2 additions & 1 deletion core/e2e/tests/checkpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
15 changes: 6 additions & 9 deletions core/e2e/tests/epoch_change.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -241,20 +242,16 @@ 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<NodePublicKey> = response.into_iter().collect();

current_committee
.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 {
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion core/e2e/tests/pinger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion core/e2e/tests/syncronizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions core/rpc/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub fn make_plain_rpc_client(address: &str) -> anyhow::Result<HttpClient<HttpBac
.context(format!("Trying to build rpc client for {address}"))
}

/// An HTTP JSON RPC client compatible with [`jsonrpsee`] derived servers
pub enum RpcClient {
WithHmac(HmacClient),
Http(HttpClient<HttpBackend>),
Expand Down
17 changes: 10 additions & 7 deletions core/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
3 changes: 2 additions & 1 deletion core/syncronizer/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit f03720a

Please sign in to comment.