]> Untitled Git - bdk/commitdiff
Implement `Deref<Target=Client>` for `ElectrumBlockchain`
authorAlekos Filini <alekos.filini@gmail.com>
Mon, 8 Aug 2022 10:03:35 +0000 (12:03 +0200)
committerAlekos Filini <alekos.filini@gmail.com>
Mon, 8 Aug 2022 10:03:35 +0000 (12:03 +0200)
As pointed out in https://github.com/bitcoindevkit/rust-electrum-client/pull/58#issuecomment-1207890096
there was no way to keep using the client once it was given to BDK.

src/blockchain/electrum.rs

index c1e1c66cfa4072d3a2d7d5f9aba803117fd3d615..fdb10b470f2a60bdd28a27154cefed10da982e0d 100644 (file)
@@ -25,6 +25,7 @@
 //! ```
 
 use std::collections::{HashMap, HashSet};
+use std::ops::Deref;
 
 #[allow(unused_imports)]
 use log::{debug, error, info, trace};
@@ -79,6 +80,14 @@ impl Blockchain for ElectrumBlockchain {
     }
 }
 
+impl Deref for ElectrumBlockchain {
+    type Target = Client;
+
+    fn deref(&self) -> &Self::Target {
+        &self.client
+    }
+}
+
 impl StatelessBlockchain for ElectrumBlockchain {}
 
 impl GetHeight for ElectrumBlockchain {