remove option & remove block check
This commit is contained in:
parent
97bffd03d0
commit
1be4d54035
@ -1102,10 +1102,10 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
pub fn get_blobs_checking_early_attester_cache(
|
||||
&self,
|
||||
block_root: &Hash256,
|
||||
) -> Result<Option<BlobSidecarList<T::EthSpec>>, Error> {
|
||||
) -> Result<BlobSidecarList<T::EthSpec>, Error> {
|
||||
self.early_attester_cache
|
||||
.get_blobs(*block_root)
|
||||
.map_or_else(|| self.get_blobs(block_root), |blobs| Ok(Some(blobs)))
|
||||
.map_or_else(|| self.get_blobs(block_root), |blobs| Ok(blobs))
|
||||
}
|
||||
|
||||
/// Returns the block at the given root, if any.
|
||||
@ -1188,18 +1188,11 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
pub fn get_blobs(
|
||||
&self,
|
||||
block_root: &Hash256,
|
||||
) -> Result<Option<BlobSidecarList<T::EthSpec>>, Error> {
|
||||
|
||||
let blobs = self.store.get_blobs(block_root)?;
|
||||
match Some(blobs) {
|
||||
) -> Result<BlobSidecarList<T::EthSpec>, Error> {
|
||||
match self.store.get_blobs(block_root)? {
|
||||
Some(blobs) => Ok(blobs),
|
||||
None => {
|
||||
// if there are no blobs, but a block exists return an empty list
|
||||
if let Some(_) = self.store.try_get_full_block(block_root)? {
|
||||
return Ok(Some(BlobSidecarList::default()))
|
||||
}
|
||||
// if there is no blob and no block return none.
|
||||
Ok(None)
|
||||
Ok(BlobSidecarList::default())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -698,14 +698,14 @@ where
|
||||
let block = self.chain.head_beacon_block();
|
||||
let block_root = block.canonical_root();
|
||||
let blobs = self.chain.get_blobs(&block_root).unwrap();
|
||||
RpcBlock::new(block, blobs).unwrap()
|
||||
RpcBlock::new(block, Some(blobs)).unwrap()
|
||||
}
|
||||
|
||||
pub fn get_full_block(&self, block_root: &Hash256) -> RpcBlock<E> {
|
||||
let block = self.chain.get_blinded_block(block_root).unwrap().unwrap();
|
||||
let full_block = self.chain.store.make_full_block(block_root, block).unwrap();
|
||||
let blobs = self.chain.get_blobs(block_root).unwrap();
|
||||
RpcBlock::new(Arc::new(full_block), blobs).unwrap()
|
||||
RpcBlock::new(Arc::new(full_block), Some(blobs)).unwrap()
|
||||
}
|
||||
|
||||
pub fn get_all_validators(&self) -> Vec<usize> {
|
||||
|
@ -258,14 +258,9 @@ impl BlockId {
|
||||
chain: &BeaconChain<T>,
|
||||
) -> Result<BlobSidecarList<T::EthSpec>, warp::Rejection> {
|
||||
let root = self.root(chain)?.0;
|
||||
match chain.get_blobs(&root) {
|
||||
Ok(Some(blob_sidecar_list)) => Ok(blob_sidecar_list),
|
||||
Ok(None) => Err(warp_utils::reject::custom_not_found(format!(
|
||||
"Block not found {} in the store",
|
||||
root
|
||||
))),
|
||||
Err(e) => Err(warp_utils::reject::beacon_chain_error(e)),
|
||||
}
|
||||
chain.get_blobs(&root).map_err(
|
||||
|e| warp_utils::reject::beacon_chain_error(e)
|
||||
)
|
||||
}
|
||||
|
||||
pub async fn blob_sidecar_list_filtered<T: BeaconChainTypes>(
|
||||
|
@ -11,7 +11,7 @@ use lighthouse_network::rpc::methods::{
|
||||
use lighthouse_network::rpc::StatusMessage;
|
||||
use lighthouse_network::rpc::*;
|
||||
use lighthouse_network::{PeerId, PeerRequestId, ReportSource, Response, SyncInfo};
|
||||
use slog::{debug, error, trace, warn};
|
||||
use slog::{debug, error, warn};
|
||||
use slot_clock::SlotClock;
|
||||
use std::collections::{hash_map::Entry, HashMap};
|
||||
use std::sync::Arc;
|
||||
@ -247,7 +247,7 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
|
||||
};
|
||||
|
||||
match blob_list_result.as_ref() {
|
||||
Ok(Some(blobs_sidecar_list)) => {
|
||||
Ok(blobs_sidecar_list) => {
|
||||
'inner: for blob_sidecar in blobs_sidecar_list.iter() {
|
||||
if blob_sidecar.index == index {
|
||||
self.send_response(
|
||||
@ -260,14 +260,6 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(None) => {
|
||||
debug!(
|
||||
self.log,
|
||||
"Peer requested unknown blobs";
|
||||
"peer" => %peer_id,
|
||||
"request_root" => ?root
|
||||
);
|
||||
}
|
||||
Err(e) => {
|
||||
debug!(
|
||||
self.log,
|
||||
@ -767,7 +759,7 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
|
||||
|
||||
for root in block_roots {
|
||||
match self.chain.get_blobs(&root) {
|
||||
Ok(Some(blob_sidecar_list)) => {
|
||||
Ok(blob_sidecar_list) => {
|
||||
for blob_sidecar in blob_sidecar_list.iter() {
|
||||
blobs_sent += 1;
|
||||
self.send_network_message(NetworkMessage::SendResponse {
|
||||
@ -777,15 +769,6 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
|
||||
});
|
||||
}
|
||||
}
|
||||
Ok(None) => {
|
||||
trace!(
|
||||
self.log,
|
||||
"No blobs in the store for block root";
|
||||
"request" => ?req,
|
||||
"peer" => %peer_id,
|
||||
"block_root" => ?root
|
||||
);
|
||||
}
|
||||
Err(e) => {
|
||||
error!(
|
||||
self.log,
|
||||
|
Loading…
Reference in New Issue
Block a user