+ self.client.lock().await.get::<F>(&uri, &host).await?.try_into()
+ }
+}
+
+impl BlockSource for RestClient {
+ fn get_header<'a>(&'a self, header_hash: &'a BlockHash, _height: Option<u32>) -> AsyncBlockSourceResult<'a, BlockHeaderData> {
+ Box::pin(async move {
+ let resource_path = format!("headers/1/{}.json", header_hash.to_hex());
+ Ok(self.request_resource::<JsonResponse, _>(&resource_path).await?)
+ })
+ }
+
+ fn get_block<'a>(&'a self, header_hash: &'a BlockHash) -> AsyncBlockSourceResult<'a, BlockData> {
+ Box::pin(async move {
+ let resource_path = format!("block/{}.bin", header_hash.to_hex());
+ Ok(BlockData::FullBlock(self.request_resource::<BinaryResponse, _>(&resource_path).await?))
+ })
+ }
+
+ fn get_best_block<'a>(&'a self) -> AsyncBlockSourceResult<'a, (BlockHash, Option<u32>)> {
+ Box::pin(async move {
+ Ok(self.request_resource::<JsonResponse, _>("chaininfo.json").await?)
+ })