Skip to content
Snippets Groups Projects
Commit efa04ed7 authored by Nazar Mokrynskyi's avatar Nazar Mokrynskyi Committed by GitHub
Browse files

Enforce blocks response limit (#12146)

parent 2b805559
No related merge requests found
......@@ -405,11 +405,20 @@ where
indexed_body,
};
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>();
let new_total_size = total_size +
block_data.body.iter().map(|ex| ex.len()).sum::<usize>() +
block_data.indexed_body.iter().map(|ex| ex.len()).sum::<usize>();
// Send at least one block, but make sure to not exceed the limit.
if !blocks.is_empty() && new_total_size > MAX_BODY_BYTES {
break
}
total_size = new_total_size;
blocks.push(block_data);
if blocks.len() >= max_blocks as usize || total_size > MAX_BODY_BYTES {
if blocks.len() >= max_blocks as usize {
break
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment