Skip to content

Commit 2f32532

Browse files
committed
Merge #596: Bump MSRV to 1.56
cca6948 Bump MSRV to 1.56 (Alekos Filini) Pull request description: ### Description Following the discussion in #331, bump the MSRV to `1.56`. We already have other PRs bumping it to at least `1.51` (#593), but I'm felling like we are always lagging behind and our CI breaks regularly. As @LLFourn suggested, this PR makes a relatively large bump, hoping this buys us enough time to finish splitting up BDK, which will allow us to have a lower MSRV for the "core" crate. ### Checklists #### All Submissions: * [x] I've signed all my commits * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md) * [x] I ran `cargo fmt` and `cargo clippy` before committing #### New Features: * [x] I've updated `CHANGELOG.md` ACKs for top commit: notmandatory: ACK cca6948 Tree-SHA512: bc6572dc94e1c4cbb6d21f6e06a9730af5763fb4811311a61a6a6ec850b5a65664a21e4a7070a3ebcd702529fbba97b2e9a43c1277b9b9f092e194f16a39bc1a
2 parents 6e8744d + cca6948 commit 2f32532

File tree

12 files changed

+35
-31
lines changed

12 files changed

+35
-31
lines changed

.github/workflows/cont_integration.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ jobs:
1010
strategy:
1111
matrix:
1212
rust:
13-
- version: 1.56.0 # STABLE
13+
- version: 1.60.0 # STABLE
1414
clippy: true
15-
- version: 1.46.0 # MSRV
15+
- version: 1.56.0 # MSRV
1616
features:
1717
- default
1818
- minimal

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
## [Unreleased]
88

99
- added `OldestFirstCoinSelection` impl to `CoinSelectionAlgorithm`
10+
- New MSRV set to `1.56`
1011

1112

1213
## [v0.18.0] - [v0.17.0]

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<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>
1414
<a href="https://codecov.io/gh/bitcoindevkit/bdk"><img src="https://codecov.io/gh/bitcoindevkit/bdk/branch/master/graph/badge.svg"/></a>
1515
<a href="https://docs.rs/bdk"><img alt="API Docs" src="https://img.shields.io/badge/docs.rs-bdk-green"/></a>
16-
<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>
16+
<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>
1717
<a href="https://discord.gg/d7NkDKm"><img alt="Chat on Discord" src="https://img.shields.io/discord/753336465005608961?logo=discord"></a>
1818
</p>
1919

examples/compiler.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ fn main() -> Result<(), Box<dyn Error>> {
8585

8686
let network = matches
8787
.value_of("network")
88-
.map(|n| Network::from_str(n))
88+
.map(Network::from_str)
8989
.transpose()
9090
.unwrap()
9191
.unwrap_or(Network::Testnet);

src/blockchain/any.rs

+21-13
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@
3434
use super::*;
3535

3636
macro_rules! impl_from {
37+
( boxed $from:ty, $to:ty, $variant:ident, $( $cfg:tt )* ) => {
38+
$( $cfg )*
39+
impl From<$from> for $to {
40+
fn from(inner: $from) -> Self {
41+
<$to>::$variant(Box::new(inner))
42+
}
43+
}
44+
};
3745
( $from:ty, $to:ty, $variant:ident, $( $cfg:tt )* ) => {
3846
$( $cfg )*
3947
impl From<$from> for $to {
@@ -68,19 +76,19 @@ pub enum AnyBlockchain {
6876
#[cfg(feature = "electrum")]
6977
#[cfg_attr(docsrs, doc(cfg(feature = "electrum")))]
7078
/// Electrum client
71-
Electrum(electrum::ElectrumBlockchain),
79+
Electrum(Box<electrum::ElectrumBlockchain>),
7280
#[cfg(feature = "esplora")]
7381
#[cfg_attr(docsrs, doc(cfg(feature = "esplora")))]
7482
/// Esplora client
75-
Esplora(esplora::EsploraBlockchain),
83+
Esplora(Box<esplora::EsploraBlockchain>),
7684
#[cfg(feature = "compact_filters")]
7785
#[cfg_attr(docsrs, doc(cfg(feature = "compact_filters")))]
7886
/// Compact filters client
79-
CompactFilters(compact_filters::CompactFiltersBlockchain),
87+
CompactFilters(Box<compact_filters::CompactFiltersBlockchain>),
8088
#[cfg(feature = "rpc")]
8189
#[cfg_attr(docsrs, doc(cfg(feature = "rpc")))]
8290
/// RPC client
83-
Rpc(rpc::RpcBlockchain),
91+
Rpc(Box<rpc::RpcBlockchain>),
8492
}
8593

8694
#[maybe_async]
@@ -141,10 +149,10 @@ impl WalletSync for AnyBlockchain {
141149
}
142150
}
143151

144-
impl_from!(electrum::ElectrumBlockchain, AnyBlockchain, Electrum, #[cfg(feature = "electrum")]);
145-
impl_from!(esplora::EsploraBlockchain, AnyBlockchain, Esplora, #[cfg(feature = "esplora")]);
146-
impl_from!(compact_filters::CompactFiltersBlockchain, AnyBlockchain, CompactFilters, #[cfg(feature = "compact_filters")]);
147-
impl_from!(rpc::RpcBlockchain, AnyBlockchain, Rpc, #[cfg(feature = "rpc")]);
152+
impl_from!(boxed electrum::ElectrumBlockchain, AnyBlockchain, Electrum, #[cfg(feature = "electrum")]);
153+
impl_from!(boxed esplora::EsploraBlockchain, AnyBlockchain, Esplora, #[cfg(feature = "esplora")]);
154+
impl_from!(boxed compact_filters::CompactFiltersBlockchain, AnyBlockchain, CompactFilters, #[cfg(feature = "compact_filters")]);
155+
impl_from!(boxed rpc::RpcBlockchain, AnyBlockchain, Rpc, #[cfg(feature = "rpc")]);
148156

149157
/// Type that can contain any of the blockchain configurations defined by the library
150158
///
@@ -207,19 +215,19 @@ impl ConfigurableBlockchain for AnyBlockchain {
207215
Ok(match config {
208216
#[cfg(feature = "electrum")]
209217
AnyBlockchainConfig::Electrum(inner) => {
210-
AnyBlockchain::Electrum(electrum::ElectrumBlockchain::from_config(inner)?)
218+
AnyBlockchain::Electrum(Box::new(electrum::ElectrumBlockchain::from_config(inner)?))
211219
}
212220
#[cfg(feature = "esplora")]
213221
AnyBlockchainConfig::Esplora(inner) => {
214-
AnyBlockchain::Esplora(esplora::EsploraBlockchain::from_config(inner)?)
222+
AnyBlockchain::Esplora(Box::new(esplora::EsploraBlockchain::from_config(inner)?))
215223
}
216224
#[cfg(feature = "compact_filters")]
217-
AnyBlockchainConfig::CompactFilters(inner) => AnyBlockchain::CompactFilters(
225+
AnyBlockchainConfig::CompactFilters(inner) => AnyBlockchain::CompactFilters(Box::new(
218226
compact_filters::CompactFiltersBlockchain::from_config(inner)?,
219-
),
227+
)),
220228
#[cfg(feature = "rpc")]
221229
AnyBlockchainConfig::Rpc(inner) => {
222-
AnyBlockchain::Rpc(rpc::RpcBlockchain::from_config(inner)?)
230+
AnyBlockchain::Rpc(Box::new(rpc::RpcBlockchain::from_config(inner)?))
223231
}
224232
})
225233
}

src/blockchain/compact_filters/peer.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,7 @@ impl Mempool {
9494
TxIdentifier::Wtxid(wtxid) => self.0.read().unwrap().wtxids.get(&wtxid).cloned(),
9595
};
9696

97-
txid.map(|txid| self.0.read().unwrap().txs.get(&txid).cloned())
98-
.flatten()
97+
txid.and_then(|txid| self.0.read().unwrap().txs.get(&txid).cloned())
9998
}
10099

101100
/// Return whether or not the mempool contains a transaction with a given txid
@@ -111,6 +110,7 @@ impl Mempool {
111110

112111
/// A Bitcoin peer
113112
#[derive(Debug)]
113+
#[allow(dead_code)]
114114
pub struct Peer {
115115
writer: Arc<Mutex<TcpStream>>,
116116
responses: Arc<RwLock<ResponsesMap>>,

src/blockchain/rpc.rs

-3
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ use std::str::FromStr;
5454
pub struct RpcBlockchain {
5555
/// Rpc client to the node, includes the wallet name
5656
client: Client,
57-
/// Network used
58-
network: Network,
5957
/// Blockchain capabilities, cached here at startup
6058
capabilities: HashSet<Capability>,
6159
/// 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 {
417415

418416
Ok(RpcBlockchain {
419417
client,
420-
network,
421418
capabilities,
422419
_storage_address: storage_address,
423420
skip_blocks: config.skip_blocks,

src/database/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,7 @@ pub(crate) trait DatabaseUtils: Database {
200200
D: FnOnce() -> Result<Option<Transaction>, Error>,
201201
{
202202
self.get_tx(txid, true)?
203-
.map(|t| t.transaction)
204-
.flatten()
203+
.and_then(|t| t.transaction)
205204
.map_or_else(default, |t| Ok(Some(t)))
206205
}
207206

src/descriptor/policy.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,8 @@ impl Satisfaction {
357357
// we map each of the combinations of elements into a tuple of ([chosen items], [conditions]). unfortunately, those items have potentially more than one
358358
// 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
359359
// consider every possible options and check whether or not they are compatible.
360-
.map(|i_vec| {
360+
// since this step can turn one item of the iterator into multiple ones, we use `flat_map()` to expand them out
361+
.flat_map(|i_vec| {
361362
mix(i_vec
362363
.iter()
363364
.map(|i| {
@@ -371,9 +372,6 @@ impl Satisfaction {
371372
.map(|x| (i_vec.clone(), x))
372373
.collect::<Vec<(Vec<usize>, Vec<Condition>)>>()
373374
})
374-
// .inspect(|x: &Vec<(Vec<usize>, Vec<Condition>)>| println!("fetch {:?}", x))
375-
// since the previous step can turn one item of the iterator into multiple ones, we call flatten to expand them out
376-
.flatten()
377375
// .inspect(|x| println!("flat {:?}", x))
378376
// try to fold all the conditions for this specific combination of indexes/options. if they are not compatible, try_fold will be Err
379377
.map(|(key, val)| {

src/wallet/export.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl FromStr for FullyNodedExport {
101101
}
102102

103103
fn remove_checksum(s: String) -> String {
104-
s.splitn(2, '#').next().map(String::from).unwrap()
104+
s.split_once('#').map(|(a, _)| String::from(a)).unwrap()
105105
}
106106

107107
impl FullyNodedExport {

src/wallet/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1603,9 +1603,9 @@ where
16031603
pub fn descriptor_checksum(&self, keychain: KeychainKind) -> String {
16041604
self.get_descriptor_for_keychain(keychain)
16051605
.to_string()
1606-
.splitn(2, '#')
1607-
.next()
1606+
.split_once('#')
16081607
.unwrap()
1608+
.0
16091609
.to_string()
16101610
}
16111611
}

src/wallet/signer.rs

+1
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,7 @@ pub struct SignOptions {
479479
pub allow_all_sighashes: bool,
480480
}
481481

482+
#[allow(clippy::derivable_impls)]
482483
impl Default for SignOptions {
483484
fn default() -> Self {
484485
SignOptions {

0 commit comments

Comments
 (0)