From f48e273560293bd2e0b9a02b4798bbf4e506b824 Mon Sep 17 00:00:00 2001 From: Jeffrey Czyz Date: Wed, 3 Mar 2021 17:32:39 -0800 Subject: [PATCH] Expose RpcClient and RestClient interfaces as pub Useful for use outside of the BlockSource context, e.g., when implementing fee estimation or transaction broadcasting. --- lightning-block-sync/src/http.rs | 4 ++-- lightning-block-sync/src/rest.rs | 2 +- lightning-block-sync/src/rpc.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lightning-block-sync/src/http.rs b/lightning-block-sync/src/http.rs index 0788bc989..a33d919d0 100644 --- a/lightning-block-sync/src/http.rs +++ b/lightning-block-sync/src/http.rs @@ -399,10 +399,10 @@ enum HttpMessageLength { } /// An HTTP response body in binary format. -pub(crate) struct BinaryResponse(pub(crate) Vec); +pub struct BinaryResponse(pub Vec); /// An HTTP response body in JSON format. -pub(crate) struct JsonResponse(pub(crate) serde_json::Value); +pub struct JsonResponse(pub serde_json::Value); /// Interprets bytes from an HTTP response body as binary data. impl TryFrom> for BinaryResponse { diff --git a/lightning-block-sync/src/rest.rs b/lightning-block-sync/src/rest.rs index 3c2e76e23..3aff104d5 100644 --- a/lightning-block-sync/src/rest.rs +++ b/lightning-block-sync/src/rest.rs @@ -24,7 +24,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); diff --git a/lightning-block-sync/src/rpc.rs b/lightning-block-sync/src/rpc.rs index 34cbd2e02..d59401e0f 100644 --- a/lightning-block-sync/src/rpc.rs +++ b/lightning-block-sync/src/rpc.rs @@ -34,7 +34,7 @@ impl RpcClient { } /// Calls a method with the response encoded in JSON format and interpreted as type `T`. - async fn call_method(&mut self, method: &str, params: &[serde_json::Value]) -> std::io::Result + pub async fn call_method(&mut self, method: &str, params: &[serde_json::Value]) -> std::io::Result where JsonResponse: TryFrom, Error = std::io::Error> + TryInto { let host = format!("{}:{}", self.endpoint.host(), self.endpoint.port()); let uri = self.endpoint.path(); -- 2.39.5