Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turn rpc::Client::new into a sync fn by not performing the health check on creation #169

Merged
merged 3 commits into from
Mar 10, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tendermint-lite/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fn main() {
let trusting_period = Duration::new(6000, 0);

// setup requester for primary peer
let client = block_on(rpc::Client::new(&RPC_ADDR.parse().unwrap())).unwrap();
let client = block_on(rpc::Client::new_healthy(RPC_ADDR.parse().unwrap())).unwrap();
let req = RPCRequester::new(client);
let mut store = MemStore::new();

Expand Down
12 changes: 8 additions & 4 deletions tendermint/src/rpc/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@ pub struct Client {

impl Client {
/// Create a new Tendermint RPC client, connecting to the given address
pub async fn new(address: &net::Address) -> Result<Self, Error> {
let client = Client {
address: address.clone(),
};
pub fn new(address: net::Address) -> Self {
Self { address }
}

/// Create a new Tendermint RPC client, connecting to the given address,
/// and perform a health check.
pub async fn new_healthy(address: net::Address) -> Result<Self, Error> {
let client = Self::new(address);
client.health().await?;
Ok(client)
}
Expand Down