mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-08 17:26:04 +00:00
fix bug in matching blocks and blobs in range sync
This commit is contained in:
@@ -56,13 +56,17 @@ impl<T: EthSpec> BlocksAndBlobsRequestInfo<T> {
|
|||||||
if blob_list.is_empty() {
|
if blob_list.is_empty() {
|
||||||
responses.push(BlockWrapper::Block(block))
|
responses.push(BlockWrapper::Block(block))
|
||||||
} else {
|
} else {
|
||||||
let mut blobs_fixed = Vec::with_capacity(T::max_blobs_per_block());
|
let mut blobs_fixed = vec![None; T::max_blobs_per_block()];
|
||||||
for blob in blob_list {
|
for blob in blob_list {
|
||||||
let blob_index = blob.index as usize;
|
let blob_index = blob.index as usize;
|
||||||
if blob_index >= T::max_blobs_per_block() {
|
let Some(blob_opt) = blobs_fixed.get_mut(blob_index) else {
|
||||||
return Err("Invalid blob index");
|
return Err("Invalid blob index");
|
||||||
|
};
|
||||||
|
if blob_opt.is_some() {
|
||||||
|
return Err("Repeat blob index");
|
||||||
|
} else {
|
||||||
|
*blob_opt = Some(blob);
|
||||||
}
|
}
|
||||||
blobs_fixed.insert(blob_index, Some(blob));
|
|
||||||
}
|
}
|
||||||
responses.push(BlockWrapper::BlockAndBlobs(
|
responses.push(BlockWrapper::BlockAndBlobs(
|
||||||
block,
|
block,
|
||||||
|
|||||||
Reference in New Issue
Block a user