+use std::ops::Deref;
+
+/// Returns a validated block header of the source's best chain tip.
+///
+/// Upon success, the returned header can be used to initialize [`SpvClient`]. Useful during a fresh
+/// start when there are no chain listeners to sync yet.
+///
+/// [`SpvClient`]: crate::SpvClient
+pub async fn validate_best_block_header<B: Deref>(block_source: B) ->
+BlockSourceResult<ValidatedBlockHeader> where B::Target: BlockSource {
+ let (best_block_hash, best_block_height) = block_source.get_best_block().await?;
+ block_source
+ .get_header(&best_block_hash, best_block_height).await?
+ .validate(best_block_hash)
+}
+