mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
fix: increase minimum request timeout (#1078)
This commit is contained in:
@ -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;
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
Reference in New Issue
Block a user