fix: increase minimum request timeout (#1078)

This commit is contained in:
Matthias Seitz
2023-01-30 16:10:50 +01:00
committed by GitHub
parent 6f89ad086b
commit 6b795be77f
2 changed files with 4 additions and 4 deletions

View File

@ -81,7 +81,7 @@ pub(crate) struct ActiveSession {
/// Constants for timeout updating
/// Minimum timeout value
const MINIMUM_TIMEOUT: Duration = Duration::from_millis(1);
const MINIMUM_TIMEOUT: Duration = Duration::from_secs(2);
/// Maximum timeout value
const MAXIMUM_TIMEOUT: Duration = INITIAL_REQUEST_TIMEOUT;
/// How much the new measurements affect the current timeout (X percent)
@ -204,7 +204,7 @@ impl ActiveSession {
None
}
/// Handle an incoming peer request.
/// Handle an internal peer request that will be sent to the remote.
fn on_peer_request(&mut self, request: PeerRequest, deadline: Instant) {
let request_id = self.next_id();
let msg = request.create_request_message(request_id);
@ -839,7 +839,7 @@ mod tests {
#[test]
fn timeout_calculation_sanity_tests() {
let rtt = Duration::from_millis(200);
let rtt = Duration::from_secs(5);
// timeout for an RTT of `rtt`
let timeout = rtt * TIMEOUT_SCALING;

View File

@ -113,7 +113,7 @@ async fn test_get_header() {
HeadersRequest { start: hash.into(), limit: 1, direction: HeadersDirection::Falling };
let res = fetch0.get_headers(req).await;
assert!(res.is_ok());
assert!(res.is_ok(), "{res:?}");
let headers = res.unwrap().1 .0;
assert_eq!(headers.len(), 1);