Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

BlockId removal: refactor: BlockBackend::block|block_status #13014

Merged
merged 5 commits into from
Jan 2, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Apply suggestions from code review
Co-authored-by: Bastian Köcher <git@kchr.de>
  • Loading branch information
michalkucharczyk and bkchr authored Jan 2, 2023
commit 55762bb155f080cbd0ec7e4290650a8e9507d7fa
14 changes: 7 additions & 7 deletions client/service/test/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1497,15 +1497,15 @@ fn returns_status_for_pruned_blocks() {
block_on(client.check_block(check_block_a1.clone())).unwrap(),
ImportResult::imported(false),
);
assert_eq!(client.block_status(check_block_a1.hash).unwrap(), BlockStatus::Unknown,);
assert_eq!(client.block_status(check_block_a1.hash).unwrap(), BlockStatus::Unknown);

block_on(client.import_as_final(BlockOrigin::Own, a1.clone())).unwrap();

assert_eq!(
block_on(client.check_block(check_block_a1.clone())).unwrap(),
ImportResult::AlreadyInChain,
);
assert_eq!(client.block_status(check_block_a1.hash).unwrap(), BlockStatus::InChainWithState,);
assert_eq!(client.block_status(check_block_a1.hash).unwrap(), BlockStatus::InChainWithState);

let a2 = client
.new_block_at(&BlockId::Hash(a1.hash()), Default::default(), false)
Expand All @@ -1528,12 +1528,12 @@ fn returns_status_for_pruned_blocks() {
block_on(client.check_block(check_block_a1.clone())).unwrap(),
ImportResult::AlreadyInChain,
);
assert_eq!(client.block_status(check_block_a1.hash).unwrap(), BlockStatus::InChainPruned,);
assert_eq!(client.block_status(check_block_a1.hash).unwrap(), BlockStatus::InChainPruned);
assert_eq!(
block_on(client.check_block(check_block_a2.clone())).unwrap(),
ImportResult::AlreadyInChain,
);
assert_eq!(client.block_status(check_block_a2.hash).unwrap(), BlockStatus::InChainWithState,);
assert_eq!(client.block_status(check_block_a2.hash).unwrap(), BlockStatus::InChainWithState);

let a3 = client
.new_block_at(&BlockId::Hash(a2.hash()), Default::default(), false)
Expand All @@ -1557,17 +1557,17 @@ fn returns_status_for_pruned_blocks() {
block_on(client.check_block(check_block_a1.clone())).unwrap(),
ImportResult::AlreadyInChain,
);
assert_eq!(client.block_status(check_block_a1.hash).unwrap(), BlockStatus::InChainPruned,);
assert_eq!(client.block_status(check_block_a1.hash).unwrap(), BlockStatus::InChainPruned);
assert_eq!(
block_on(client.check_block(check_block_a2.clone())).unwrap(),
ImportResult::AlreadyInChain,
);
assert_eq!(client.block_status(check_block_a2.hash).unwrap(), BlockStatus::InChainPruned,);
assert_eq!(client.block_status(check_block_a2.hash).unwrap(), BlockStatus::InChainPruned);
assert_eq!(
block_on(client.check_block(check_block_a3.clone())).unwrap(),
ImportResult::AlreadyInChain,
);
assert_eq!(client.block_status(check_block_a3.hash).unwrap(), BlockStatus::InChainWithState,);
assert_eq!(client.block_status(check_block_a3.hash).unwrap(), BlockStatus::InChainWithState);

let mut check_block_b1 = BlockCheckParams {
hash: b1.hash(),
Expand Down
2 changes: 1 addition & 1 deletion primitives/consensus/common/src/block_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use std::{error::Error, future::Future, pin::Pin, sync::Arc};

/// A type which provides access to chain information.
pub trait Chain<B: Block> {
/// Retrieve the status of the block denoted by the given [`Block::hash`].
/// Retrieve the status of the block denoted by the given [`Block::Hash`].
fn block_status(&self, hash: B::Hash) -> Result<BlockStatus, Box<dyn Error + Send>>;
}

Expand Down