Skip to content
This repository has been archived by the owner on Jun 3, 2020. It is now read-only.

Experiment with adding timeouts to tpc socket #356

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
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
8 changes: 7 additions & 1 deletion src/connection/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ use crate::{
};
use signatory::{ed25519, PublicKeyed};
use signatory_dalek::Ed25519Signer;
use std::net::TcpStream;
use std::{
net::TcpStream,
time::Duration,
};
use subtle::ConstantTimeEq;
use tendermint::node;
pub use tendermint::secret_connection::{PublicKey, SecretConnection};


/// Open a TCP socket connection encrypted with SecretConnection
pub fn open_secret_connection(
host: &str,
Expand All @@ -24,6 +28,8 @@ pub fn open_secret_connection(
info!("KMS node ID: {}", &public_key);

let socket = TcpStream::connect(format!("{}:{}", host, port))?;
socket.set_read_timeout(Some(Duration::from_secs(5)))?;
socket.set_write_timeout(Some(Duration::from_secs(5)))?;
let connection = SecretConnection::new(socket, &public_key, &signer)?;
let actual_peer_id = connection.remote_pubkey().peer_id();

Expand Down