Fixed block response limit check (#9692)

* Fixed block response limit check

* Fixed start block detection and added a test

* Missing test
This commit is contained in:
Arkadiy Paronyan
2021-09-06 09:25:30 +02:00
committed by GitHub
parent ffced22fb7
commit cd19c7b79e
5 changed files with 45 additions and 12 deletions
@@ -62,7 +62,7 @@ pub fn generate_protocol_config(protocol_id: &ProtocolId) -> ProtocolConfig {
name: generate_protocol_name(protocol_id).into(),
max_request_size: 1024 * 1024,
max_response_size: 16 * 1024 * 1024,
request_timeout: Duration::from_secs(40),
request_timeout: Duration::from_secs(20),
inbound_queue: None,
}
}
@@ -355,7 +355,8 @@ impl<B: BlockT> BlockRequestHandler<B> {
indexed_body,
};
total_size += block_data.body.len();
total_size += block_data.body.iter().map(|ex| ex.len()).sum::<usize>();
total_size += block_data.indexed_body.iter().map(|ex| ex.len()).sum::<usize>();
blocks.push(block_data);
if blocks.len() >= max_blocks as usize || total_size > MAX_BODY_BYTES {