mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 16:57:58 +00:00
Enforce blocks response limit (#12146)
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user