]> Untitled Git - bdk/commitdiff
Bump MSRV to 1.56
authorAlekos Filini <alekos.filini@gmail.com>
Tue, 3 May 2022 10:41:22 +0000 (12:41 +0200)
committerAlekos Filini <alekos.filini@gmail.com>
Wed, 4 May 2022 15:29:07 +0000 (17:29 +0200)
12 files changed:
.github/workflows/cont_integration.yml
CHANGELOG.md
README.md
examples/compiler.rs
src/blockchain/any.rs
src/blockchain/compact_filters/peer.rs
src/blockchain/rpc.rs
src/database/mod.rs
src/descriptor/policy.rs
src/wallet/export.rs
src/wallet/mod.rs
src/wallet/signer.rs

index badcd2e6850b0812991133a4259687eba0cc432a..091ba15726a1f97e82be634179ca9a81f1610b87 100644 (file)
@@ -10,9 +10,9 @@ jobs:
     strategy:
       matrix:
         rust:
-          - version: 1.56.0 # STABLE
+          - version: 1.60.0 # STABLE
             clippy: true
-          - version: 1.46.0 # MSRV
+          - version: 1.56.0 # MSRV
         features:
           - default
           - minimal
index 6506d12decc032fa07d9fb0cb96a4aca4f29b21c..5cb9f31c3f7378d2efe7f1c813dc73b34ce7a6d5 100644 (file)
@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 ## [Unreleased]
 
 - added `OldestFirstCoinSelection` impl to `CoinSelectionAlgorithm`
+- New MSRV set to `1.56`
 
 
 ## [v0.18.0] - [v0.17.0]
index 8f2c7e74959ec47ef8e6a127f287b9f42af4c642..10ae41c0324b5c4d30e3f9402b6b45dfe35f5ac0 100644 (file)
--- a/README.md
+++ b/README.md
@@ -13,7 +13,7 @@
     <a href="https://github.com/bitcoindevkit/bdk/actions?query=workflow%3ACI"><img alt="CI Status" src="https://github.com/bitcoindevkit/bdk/workflows/CI/badge.svg"></a>
     <a href="https://codecov.io/gh/bitcoindevkit/bdk"><img src="https://codecov.io/gh/bitcoindevkit/bdk/branch/master/graph/badge.svg"/></a>
     <a href="https://docs.rs/bdk"><img alt="API Docs" src="https://img.shields.io/badge/docs.rs-bdk-green"/></a>
-    <a href="https://blog.rust-lang.org/2020/08/27/Rust-1.46.0.html"><img alt="Rustc Version 1.46+" src="https://img.shields.io/badge/rustc-1.46%2B-lightgrey.svg"/></a>
+    <a href="https://blog.rust-lang.org/2020/08/27/Rust-1.56.0.html"><img alt="Rustc Version 1.56+" src="https://img.shields.io/badge/rustc-1.56%2B-lightgrey.svg"/></a>
     <a href="https://discord.gg/d7NkDKm"><img alt="Chat on Discord" src="https://img.shields.io/discord/753336465005608961?logo=discord"></a>
   </p>
 
index c3a3cb4f3da40233fd10523ddd0e26b1579bbb2a..8be87e8122db5505b6bc26e961d53e6af99caef5 100644 (file)
@@ -85,7 +85,7 @@ fn main() -> Result<(), Box<dyn Error>> {
 
     let network = matches
         .value_of("network")
-        .map(|n| Network::from_str(n))
+        .map(Network::from_str)
         .transpose()
         .unwrap()
         .unwrap_or(Network::Testnet);
index 91f448b389acd63af8856e4a206b06d87672b053..b669846298b1cd12e1c78b7ceff7712e9f82b4ba 100644 (file)
 use super::*;
 
 macro_rules! impl_from {
+    ( boxed $from:ty, $to:ty, $variant:ident, $( $cfg:tt )* ) => {
+        $( $cfg )*
+        impl From<$from> for $to {
+            fn from(inner: $from) -> Self {
+                <$to>::$variant(Box::new(inner))
+            }
+        }
+    };
     ( $from:ty, $to:ty, $variant:ident, $( $cfg:tt )* ) => {
         $( $cfg )*
         impl From<$from> for $to {
@@ -68,19 +76,19 @@ pub enum AnyBlockchain {
     #[cfg(feature = "electrum")]
     #[cfg_attr(docsrs, doc(cfg(feature = "electrum")))]
     /// Electrum client
-    Electrum(electrum::ElectrumBlockchain),
+    Electrum(Box<electrum::ElectrumBlockchain>),
     #[cfg(feature = "esplora")]
     #[cfg_attr(docsrs, doc(cfg(feature = "esplora")))]
     /// Esplora client
-    Esplora(esplora::EsploraBlockchain),
+    Esplora(Box<esplora::EsploraBlockchain>),
     #[cfg(feature = "compact_filters")]
     #[cfg_attr(docsrs, doc(cfg(feature = "compact_filters")))]
     /// Compact filters client
-    CompactFilters(compact_filters::CompactFiltersBlockchain),
+    CompactFilters(Box<compact_filters::CompactFiltersBlockchain>),
     #[cfg(feature = "rpc")]
     #[cfg_attr(docsrs, doc(cfg(feature = "rpc")))]
     /// RPC client
-    Rpc(rpc::RpcBlockchain),
+    Rpc(Box<rpc::RpcBlockchain>),
 }
 
 #[maybe_async]
@@ -141,10 +149,10 @@ impl WalletSync for AnyBlockchain {
     }
 }
 
-impl_from!(electrum::ElectrumBlockchain, AnyBlockchain, Electrum, #[cfg(feature = "electrum")]);
-impl_from!(esplora::EsploraBlockchain, AnyBlockchain, Esplora, #[cfg(feature = "esplora")]);
-impl_from!(compact_filters::CompactFiltersBlockchain, AnyBlockchain, CompactFilters, #[cfg(feature = "compact_filters")]);
-impl_from!(rpc::RpcBlockchain, AnyBlockchain, Rpc, #[cfg(feature = "rpc")]);
+impl_from!(boxed electrum::ElectrumBlockchain, AnyBlockchain, Electrum, #[cfg(feature = "electrum")]);
+impl_from!(boxed esplora::EsploraBlockchain, AnyBlockchain, Esplora, #[cfg(feature = "esplora")]);
+impl_from!(boxed compact_filters::CompactFiltersBlockchain, AnyBlockchain, CompactFilters, #[cfg(feature = "compact_filters")]);
+impl_from!(boxed rpc::RpcBlockchain, AnyBlockchain, Rpc, #[cfg(feature = "rpc")]);
 
 /// Type that can contain any of the blockchain configurations defined by the library
 ///
@@ -207,19 +215,19 @@ impl ConfigurableBlockchain for AnyBlockchain {
         Ok(match config {
             #[cfg(feature = "electrum")]
             AnyBlockchainConfig::Electrum(inner) => {
-                AnyBlockchain::Electrum(electrum::ElectrumBlockchain::from_config(inner)?)
+                AnyBlockchain::Electrum(Box::new(electrum::ElectrumBlockchain::from_config(inner)?))
             }
             #[cfg(feature = "esplora")]
             AnyBlockchainConfig::Esplora(inner) => {
-                AnyBlockchain::Esplora(esplora::EsploraBlockchain::from_config(inner)?)
+                AnyBlockchain::Esplora(Box::new(esplora::EsploraBlockchain::from_config(inner)?))
             }
             #[cfg(feature = "compact_filters")]
-            AnyBlockchainConfig::CompactFilters(inner) => AnyBlockchain::CompactFilters(
+            AnyBlockchainConfig::CompactFilters(inner) => AnyBlockchain::CompactFilters(Box::new(
                 compact_filters::CompactFiltersBlockchain::from_config(inner)?,
-            ),
+            )),
             #[cfg(feature = "rpc")]
             AnyBlockchainConfig::Rpc(inner) => {
-                AnyBlockchain::Rpc(rpc::RpcBlockchain::from_config(inner)?)
+                AnyBlockchain::Rpc(Box::new(rpc::RpcBlockchain::from_config(inner)?))
             }
         })
     }
index f415d285e0a7970aa081337adcdc6154bcf7d4e6..a8d65aa947ee0d640ef1207b65da9b663bf4094f 100644 (file)
@@ -94,8 +94,7 @@ impl Mempool {
             TxIdentifier::Wtxid(wtxid) => self.0.read().unwrap().wtxids.get(&wtxid).cloned(),
         };
 
-        txid.map(|txid| self.0.read().unwrap().txs.get(&txid).cloned())
-            .flatten()
+        txid.and_then(|txid| self.0.read().unwrap().txs.get(&txid).cloned())
     }
 
     /// Return whether or not the mempool contains a transaction with a given txid
@@ -111,6 +110,7 @@ impl Mempool {
 
 /// A Bitcoin peer
 #[derive(Debug)]
+#[allow(dead_code)]
 pub struct Peer {
     writer: Arc<Mutex<TcpStream>>,
     responses: Arc<RwLock<ResponsesMap>>,
index e8da3451b03bc7ddcfc9f7705e3643daeeb915d7..78d166e3a79d270e45441724d6e6dbacea9a153b 100644 (file)
@@ -54,8 +54,6 @@ use std::str::FromStr;
 pub struct RpcBlockchain {
     /// Rpc client to the node, includes the wallet name
     client: Client,
-    /// Network used
-    network: Network,
     /// Blockchain capabilities, cached here at startup
     capabilities: HashSet<Capability>,
     /// Skip this many blocks of the blockchain at the first rescan, if None the rescan is done from the genesis block
@@ -417,7 +415,6 @@ impl ConfigurableBlockchain for RpcBlockchain {
 
         Ok(RpcBlockchain {
             client,
-            network,
             capabilities,
             _storage_address: storage_address,
             skip_blocks: config.skip_blocks,
index 8141ede4fcd404e8cfdc34103a529066ef7cbecd..e31d3a1edf3067a0076d6e95960963ccd1a96250 100644 (file)
@@ -200,8 +200,7 @@ pub(crate) trait DatabaseUtils: Database {
         D: FnOnce() -> Result<Option<Transaction>, Error>,
     {
         self.get_tx(txid, true)?
-            .map(|t| t.transaction)
-            .flatten()
+            .and_then(|t| t.transaction)
             .map_or_else(default, |t| Ok(Some(t)))
     }
 
index d89368de4012ae91a5c8648968f30e5177e095af..8716a86cfd2dfb7f71cea45832183bf01b925b78 100644 (file)
@@ -357,7 +357,8 @@ impl Satisfaction {
                     // we map each of the combinations of elements into a tuple of ([chosen items], [conditions]). unfortunately, those items have potentially more than one
                     // condition (think about ORs), so we also use `mix` to expand those, i.e. [[0], [1, 2]] becomes [[0, 1], [0, 2]]. This is necessary to make sure that we
                     // consider every possible options and check whether or not they are compatible.
-                    .map(|i_vec| {
+                    // since this step can turn one item of the iterator into multiple ones, we use `flat_map()` to expand them out
+                    .flat_map(|i_vec| {
                         mix(i_vec
                             .iter()
                             .map(|i| {
@@ -371,9 +372,6 @@ impl Satisfaction {
                         .map(|x| (i_vec.clone(), x))
                         .collect::<Vec<(Vec<usize>, Vec<Condition>)>>()
                     })
-                    // .inspect(|x: &Vec<(Vec<usize>, Vec<Condition>)>| println!("fetch {:?}", x))
-                    // since the previous step can turn one item of the iterator into multiple ones, we call flatten to expand them out
-                    .flatten()
                     // .inspect(|x| println!("flat {:?}", x))
                     // try to fold all the conditions for this specific combination of indexes/options. if they are not compatible, try_fold will be Err
                     .map(|(key, val)| {
index 026083e018b0eb84e151d48dfbfb68468ff0a42c..9c7532119bae63b1069f4b141f321af9eb7a5227 100644 (file)
@@ -101,7 +101,7 @@ impl FromStr for FullyNodedExport {
 }
 
 fn remove_checksum(s: String) -> String {
-    s.splitn(2, '#').next().map(String::from).unwrap()
+    s.split_once('#').map(|(a, _)| String::from(a)).unwrap()
 }
 
 impl FullyNodedExport {
index 016c0cacc188d4278f1db1da345c2d60cbb7c449..75669559cf16236c2ae9729956399a5267068bdf 100644 (file)
@@ -1603,9 +1603,9 @@ where
     pub fn descriptor_checksum(&self, keychain: KeychainKind) -> String {
         self.get_descriptor_for_keychain(keychain)
             .to_string()
-            .splitn(2, '#')
-            .next()
+            .split_once('#')
             .unwrap()
+            .0
             .to_string()
     }
 }
index 15cec186efbac7a726f71438017fca59dc2ca179..d1db87d319fe692b5cd5fa2b9a7eff100cf481f2 100644 (file)
@@ -479,6 +479,7 @@ pub struct SignOptions {
     pub allow_all_sighashes: bool,
 }
 
+#[allow(clippy::derivable_impls)]
 impl Default for SignOptions {
     fn default() -> Self {
         SignOptions {