Return target_hash for finality_target instead of an Option (#9867)

* .

cargo +nightly fmt --all

* Fix test

* Simplify test

* They are already imported

* Needless clone()
This commit is contained in:
Liu-Cheng Xu
2021-09-29 21:03:09 +08:00
committed by GitHub
parent 2deed49706
commit 802afa9f22
5 changed files with 96 additions and 378 deletions
@@ -1165,7 +1165,7 @@ where
debug!(target: "afg", "Finding best chain containing block {:?} with number limit {:?}", block, limit);
let result = match select_chain.finality_target(block, None).await {
Ok(Some(best_hash)) => {
Ok(best_hash) => {
let best_header = client
.header(BlockId::Hash(best_hash))?
.expect("Header known to exist after `finality_target` call; qed");
@@ -1223,10 +1223,6 @@ where
})
.or_else(|| Some((target_header.hash(), *target_header.number())))
},
Ok(None) => {
debug!(target: "afg", "Encountered error finding best chain containing {:?}: couldn't find target block", block);
None
},
Err(e) => {
debug!(target: "afg", "Encountered error finding best chain containing {:?}: {:?}", block, e);
None
@@ -118,10 +118,10 @@ where
)
.await
} else {
Ok(Some(pending_change.canon_hash))
Ok(pending_change.canon_hash)
};
if let Ok(Some(hash)) = effective_block_hash {
if let Ok(hash) = effective_block_hash {
if let Ok(Some(header)) = self.inner.header(BlockId::Hash(hash)) {
if *header.number() == pending_change.effective_number() {
out.push((header.hash(), *header.number()));