mirror of
https://gitlab.com/pulsechaincom/lighthouse-pulse.git
synced 2024-12-22 11:41:28 +00:00
add forK_choice_read_lock as parameter (#4978)
This commit is contained in:
parent
7f64738085
commit
a3fb27c99b
@ -838,10 +838,11 @@ impl<T: BeaconChainTypes> GossipVerifiedBlock<T> {
|
|||||||
&fork_choice_read_lock,
|
&fork_choice_read_lock,
|
||||||
block,
|
block,
|
||||||
)?;
|
)?;
|
||||||
drop(fork_choice_read_lock);
|
|
||||||
|
|
||||||
let block_epoch = block.slot().epoch(T::EthSpec::slots_per_epoch());
|
let block_epoch = block.slot().epoch(T::EthSpec::slots_per_epoch());
|
||||||
let (parent_block, block) = verify_parent_block_is_known(block_root, chain, block)?;
|
let (parent_block, block) =
|
||||||
|
verify_parent_block_is_known::<T>(block_root, &fork_choice_read_lock, block)?;
|
||||||
|
drop(fork_choice_read_lock);
|
||||||
|
|
||||||
// Track the number of skip slots between the block and its parent.
|
// Track the number of skip slots between the block and its parent.
|
||||||
metrics::set_gauge(
|
metrics::set_gauge(
|
||||||
@ -1775,14 +1776,10 @@ pub fn get_block_root<E: EthSpec>(block: &SignedBeaconBlock<E>) -> Hash256 {
|
|||||||
#[allow(clippy::type_complexity)]
|
#[allow(clippy::type_complexity)]
|
||||||
fn verify_parent_block_is_known<T: BeaconChainTypes>(
|
fn verify_parent_block_is_known<T: BeaconChainTypes>(
|
||||||
block_root: Hash256,
|
block_root: Hash256,
|
||||||
chain: &BeaconChain<T>,
|
fork_choice_read_lock: &RwLockReadGuard<BeaconForkChoice<T>>,
|
||||||
block: Arc<SignedBeaconBlock<T::EthSpec>>,
|
block: Arc<SignedBeaconBlock<T::EthSpec>>,
|
||||||
) -> Result<(ProtoBlock, Arc<SignedBeaconBlock<T::EthSpec>>), BlockError<T::EthSpec>> {
|
) -> Result<(ProtoBlock, Arc<SignedBeaconBlock<T::EthSpec>>), BlockError<T::EthSpec>> {
|
||||||
if let Some(proto_block) = chain
|
if let Some(proto_block) = fork_choice_read_lock.get_block(&block.parent_root()) {
|
||||||
.canonical_head
|
|
||||||
.fork_choice_read_lock()
|
|
||||||
.get_block(&block.parent_root())
|
|
||||||
{
|
|
||||||
Ok((proto_block, block))
|
Ok((proto_block, block))
|
||||||
} else {
|
} else {
|
||||||
Err(BlockError::ParentUnknown(RpcBlock::new_without_blobs(
|
Err(BlockError::ParentUnknown(RpcBlock::new_without_blobs(
|
||||||
|
Loading…
Reference in New Issue
Block a user