mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-11 18:04:18 +00:00
Correct parent lookup (#1027)
* Correct parent-lookup with block gossip verification * Further update port conflicts in tests
This commit is contained in:
@@ -490,9 +490,17 @@ impl<T: BeaconChainTypes> Processor<T> {
|
||||
/// across the network.
|
||||
pub fn should_forward_block(
|
||||
&mut self,
|
||||
peer_id: &PeerId,
|
||||
block: Box<SignedBeaconBlock<T::EthSpec>>,
|
||||
) -> Result<GossipVerifiedBlock<T>, BlockError> {
|
||||
self.chain.verify_block_for_gossip(*block)
|
||||
let result = self.chain.verify_block_for_gossip(*block.clone());
|
||||
|
||||
if let Err(BlockError::ParentUnknown(_)) = result {
|
||||
// if we don't know the parent, start a parent lookup
|
||||
// TODO: Modify the return to avoid the block clone.
|
||||
self.send_to_sync(SyncMessage::UnknownBlock(peer_id.clone(), block));
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
/// Process a gossip message declaring a new block.
|
||||
@@ -534,7 +542,8 @@ impl<T: BeaconChainTypes> Processor<T> {
|
||||
}
|
||||
BlockProcessingOutcome::ParentUnknown { .. } => {
|
||||
// Inform the sync manager to find parents for this block
|
||||
debug!(self.log, "Block with unknown parent received";
|
||||
// This should not occur. It should be checked by `should_forward_block`
|
||||
error!(self.log, "Block with unknown parent attempted to be processed";
|
||||
"peer_id" => format!("{:?}",peer_id));
|
||||
self.send_to_sync(SyncMessage::UnknownBlock(peer_id, block));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user