pub fn send_request<W: ser::Writeable>(
		&self,
		t: Type,
		rt: Type,
		body: &W,
		expect_h: Option<(Hash)>,
	) -> Result<(), Error> {
		{
			let expects = self.expected_responses.lock().unwrap();
			let existing = expects.iter().find(|x| {
				x.msg_type == rt && x.hash == expect_h
			});
			if let Some(x) = existing {
				trace!(
					LOGGER,
					"timeout_conn: in_flight: {:?}, {:?} (skipping)",
					x.msg_type,
					x.hash,
				);
				return Ok(())
			}
		}

		let _sent = try!(self.underlying.send_msg(t, body));

		{
			let mut expects = self.expected_responses.lock().unwrap();
			let req = InFlightRequest {
				msg_type: rt,
				hash: expect_h,
				time: Instant::now(),
			};
			trace!(
				LOGGER,
				"timeout_conn: registering: {:?}, {:?}",
				req.msg_type,
				req.hash,
			);
			expects.push(req);
		}

		Ok(())
	}
/// Sends a request and registers a timer on the provided message type and
/// optionally the hash of the sent data.
/// Skips the request if we have already sent the same response and
/// we are still waiting for a response (not yet timed out).
Sends a request and registers a timer on the provided message type and
optionally the hash of the sent data.
Skips the request if we have already sent the same response and
we are still waiting for a response (not yet timed out).
Sends a request and registers a timer on the provided message type and optionally the hash of the sent data . Skips the request if we have already sent the same response and we are still waiting for a response ( not yet timed out ) .
pub fn send_request<W: ser::Writeable>(
		&self,
		t: Type,
		rt: Type,
		body: &W,
		expect_h: Option<(Hash)>,
	) -> Result<(), Error> {
		{
			let expects = self.expected_responses.lock().unwrap();
			let existing = expects.iter().find(|x| {
				x.msg_type == rt && x.hash == expect_h
			});
			if let Some(x) = existing {
				trace!(
					LOGGER,
					"timeout_conn: in_flight: {:?}, {:?} (skipping)",
					x.msg_type,
					x.hash,
				);
				return Ok(())
			}
		}
		let _sent = try!(self.underlying.send_msg(t, body));
		{
			let mut expects = self.expected_responses.lock().unwrap();
			let req = InFlightRequest {
				msg_type: rt,
				hash: expect_h,
				time: Instant::now(),
			};
			trace!(
				LOGGER,
				"timeout_conn: registering: {:?}, {:?}",
				req.msg_type,
				req.hash,
			);
			expects.push(req);
		}
		Ok(())
	}
pub fn send_request < W : ser :: Writeable > ( & self , t : Type , rt : Type , body : & W , expect_h : Option < ( Hash ) > , ) -> Result < ( ) , Error > { { let expects = self . expected_responses . lock ( ) . unwrap ( ) ; let existing = expects . iter ( ) . find ( | x | { x . msg_type == rt && x . hash == expect_h } ) ; if let Some ( x ) = existing { trace ! ( LOGGER " " x msg_type x hash ) ; return Ok ( ( ) ) } } let _sent = try ! ( self underlying send_msg ( t body ) ) ; { let mut expects = self . expected_responses . lock ( ) . unwrap ( ) ; let req = InFlightRequest { msg_type : rt , hash : expect_h , time : Instant :: now ( ) , } ; trace ! ( LOGGER " " req msg_type req hash ) ; expects . push ( req ) ; } Ok ( ( ) ) }
Sends a request and registers a timer on the provided message type and
optionally the hash of the sent data.
Sends a request and registers a timer on the provided message type and optionally the hash of the sent data .
&self
t
Type
rt
Type
body
&W
expect_h
Option<(Hash)>