Skip to content

Commit

Permalink
fix(collator): require state to be applied to skip validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Rexagon committed Jul 4, 2024
1 parent 57a31c3 commit 45b56e8
Showing 1 changed file with 15 additions and 19 deletions.
34 changes: 15 additions & 19 deletions collator/src/validator/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,26 +416,22 @@ async fn check_and_notify_validated_by_state(
block_id: &BlockId,
listeners: &[Arc<dyn ValidatorEventListener>],
) -> Result<bool> {
if state_node_adapter
.load_block_handle(block_id)
.await?
.is_some()
{
for listener in listeners.iter() {
tokio::spawn({
let listener = listener.clone();
let block_id = *block_id;
async move {
listener
.on_block_validated(block_id, OnValidatedBlockEvent::ValidByState)
.await
.expect("Failed to notify listener");
}
});
}
return Ok(true);
match state_node_adapter.load_block_handle(block_id).await? {
Some(handle) if handle.meta().is_applied() => {}
_ => return Ok(false),
}

for listener in listeners {
let listener = listener.clone();
let block_id = *block_id;
tokio::spawn(async move {
listener
.on_block_validated(block_id, OnValidatedBlockEvent::ValidByState)
.await
.expect("Failed to notify listener");
});
}
Ok(false)
return Ok(true);
}

#[allow(clippy::too_many_arguments)]
Expand Down

0 comments on commit 45b56e8

Please sign in to comment.