Don't try to send oversized packets (#10042)

* Don't construct oversized packets

* Add test for payload limit

* [eth-sync] Fix wrongly computed data sizes

* Replace `MAX_RECEIPTS_TO_SEND` with overall softlimit
This commit is contained in:
Nicolas Gotchac
2019-01-04 19:58:21 +01:00
committed by Afri Schoedon
parent b180be7526
commit e435407080
8 changed files with 109 additions and 19 deletions

View File

@@ -41,6 +41,10 @@ const ENCRYPTED_HEADER_LEN: usize = 32;
const RECEIVE_PAYLOAD: Duration = Duration::from_secs(30);
pub const MAX_PAYLOAD_SIZE: usize = (1 << 24) - 1;
/// Network responses should try not to go over this limit.
/// This should be lower than MAX_PAYLOAD_SIZE
pub const PAYLOAD_SOFT_LIMIT: usize = (1 << 22) - 1;
pub trait GenericSocket : Read + Write {
}

View File

@@ -46,6 +46,7 @@ use ip_utils::{map_external_address, select_public_address};
use parity_path::restrict_permissions_owner;
use parking_lot::{Mutex, RwLock};
use network::{ConnectionFilter, ConnectionDirection};
use connection::PAYLOAD_SOFT_LIMIT;
type Slab<T> = ::slab::Slab<T, usize>;
@@ -200,6 +201,10 @@ impl<'s> NetworkContextTrait for NetworkContext<'s> {
.map(|node| self.reserved_peers.contains(&node))
.unwrap_or(false)
}
fn payload_soft_limit(&self) -> usize {
PAYLOAD_SOFT_LIMIT
}
}
/// Shared host information