X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning-block-sync%2Fsrc%2Frest.rs;h=e04bb86d4270f9c7aec1bc06f49a62b7af2e056a;hb=2024c5e1049ef399fb24e5c466924f980e949c69;hp=3c2e76e23d7d5ee2eebd4a957185a34fef629583;hpb=6dcb7c4d05914bdd324a82e1e72b355de0fac530;p=rust-lightning diff --git a/lightning-block-sync/src/rest.rs b/lightning-block-sync/src/rest.rs index 3c2e76e2..e04bb86d 100644 --- a/lightning-block-sync/src/rest.rs +++ b/lightning-block-sync/src/rest.rs @@ -1,3 +1,6 @@ +//! Simple REST client implementation which implements [`BlockSource`] against a Bitcoin Core REST +//! endpoint. + use crate::{BlockHeaderData, BlockSource, AsyncBlockSourceResult}; use crate::http::{BinaryResponse, HttpEndpoint, HttpClient, JsonResponse}; @@ -24,7 +27,7 @@ impl RestClient { } /// Requests a resource encoded in `F` format and interpreted as type `T`. - async fn request_resource(&mut self, resource_path: &str) -> std::io::Result + pub async fn request_resource(&mut self, resource_path: &str) -> std::io::Result where F: TryFrom, Error = std::io::Error> + TryInto { let host = format!("{}:{}", self.endpoint.host(), self.endpoint.port()); let uri = format!("{}/{}", self.endpoint.path().trim_end_matches("/"), resource_path); @@ -81,7 +84,7 @@ mod tests { let mut client = RestClient::new(server.endpoint()).unwrap(); match client.request_resource::("/").await { - Err(e) => assert_eq!(e.kind(), std::io::ErrorKind::NotFound), + Err(e) => assert_eq!(e.kind(), std::io::ErrorKind::Other), Ok(_) => panic!("Expected error"), } }