]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Merge pull request #808 from TheBlueMatt/2021-02-791-order-fix
authorMatt Corallo <649246+TheBlueMatt@users.noreply.github.com>
Fri, 5 Mar 2021 20:16:21 +0000 (12:16 -0800)
committerGitHub <noreply@github.com>
Fri, 5 Mar 2021 20:16:21 +0000 (12:16 -0800)
Process monitor update events in block_[dis]connected asynchronously

lightning-block-sync/src/http.rs
lightning-block-sync/src/rest.rs
lightning-block-sync/src/rpc.rs
lightning/src/routing/router.rs

index 0788bc989f5e3bfbdaeee747f50c7e0200e22560..a33d919d05179c7adccc8bf40fc7ed86b467bb21 100644 (file)
@@ -399,10 +399,10 @@ enum HttpMessageLength {
 }
 
 /// An HTTP response body in binary format.
-pub(crate) struct BinaryResponse(pub(crate) Vec<u8>);
+pub struct BinaryResponse(pub Vec<u8>);
 
 /// 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<Vec<u8>> for BinaryResponse {
index 3c2e76e23d7d5ee2eebd4a957185a34fef629583..3aff104d5546fe520407795d40e10307192a91ec 100644 (file)
@@ -24,7 +24,7 @@ impl RestClient {
        }
 
        /// Requests a resource encoded in `F` format and interpreted as type `T`.
-       async fn request_resource<F, T>(&mut self, resource_path: &str) -> std::io::Result<T>
+       pub async fn request_resource<F, T>(&mut self, resource_path: &str) -> std::io::Result<T>
        where F: TryFrom<Vec<u8>, Error = std::io::Error> + TryInto<T, Error = std::io::Error> {
                let host = format!("{}:{}", self.endpoint.host(), self.endpoint.port());
                let uri = format!("{}/{}", self.endpoint.path().trim_end_matches("/"), resource_path);
index 34cbd2e02c028eb51a364f431f509cabdee4c4c0..d59401e0f1c090d084f811cc6b9d8be731887ff9 100644 (file)
@@ -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<T>(&mut self, method: &str, params: &[serde_json::Value]) -> std::io::Result<T>
+       pub async fn call_method<T>(&mut self, method: &str, params: &[serde_json::Value]) -> std::io::Result<T>
        where JsonResponse: TryFrom<Vec<u8>, Error = std::io::Error> + TryInto<T, Error = std::io::Error> {
                let host = format!("{}:{}", self.endpoint.host(), self.endpoint.port());
                let uri = self.endpoint.path();
index 7819b06c0279650c17063dfaed81aebac610d884..47a261786c370f8dbd9ae3904005b72b28a44e2a 100644 (file)
@@ -946,7 +946,7 @@ pub fn get_route<L: Deref>(our_node_id: &PublicKey, network: &NetworkGraph, paye
                                // TODO: this could also be optimized by also sorting by feerate_per_sat_routed,
                                // so that the sender pays less fees overall. And also htlc_minimum_msat.
                                cur_route.sort_by_key(|path| { path.hops.iter().map(|hop| hop.channel_fees.proportional_millionths as u64).sum::<u64>() });
-                               let mut expensive_payment_path = cur_route.first_mut().unwrap();
+                               let expensive_payment_path = cur_route.first_mut().unwrap();
                                // We already dropped all the small channels above, meaning all the
                                // remaining channels are larger than remaining overpaid_value_msat.
                                // Thus, this can't be negative.
@@ -961,7 +961,7 @@ pub fn get_route<L: Deref>(our_node_id: &PublicKey, network: &NetworkGraph, paye
        // Step (8).
        // Select the best route by lowest total fee.
        drawn_routes.sort_by_key(|paths| paths.iter().map(|path| path.get_total_fee_paid_msat()).sum::<u64>());
-       let mut selected_paths = Vec::<Vec::<RouteHop>>::new();
+       let mut selected_paths = vec![];
        for payment_path in drawn_routes.first().unwrap() {
                selected_paths.push(payment_path.hops.iter().map(|payment_hop| payment_hop.route_hop.clone()).collect());
        }