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
@@ -91,11 +91,12 @@ where
&self,
target_hash: Block::Hash,
maybe_max_number: Option<NumberFor<Block>>,
) -> Result<Option<Block::Hash>, ConsensusError> {
) -> Result<Block::Hash, ConsensusError> {
let import_lock = self.backend.get_import_lock();
self.backend
.blockchain()
.best_containing(target_hash, maybe_max_number, import_lock)
.map(|maybe_hash| maybe_hash.unwrap_or(target_hash))
.map_err(|e| ConsensusError::ChainLookup(e.to_string()).into())
}
}