From cca69481eb7edb28532a4ed78185248d410050ac Mon Sep 17 00:00:00 2001
From: Alekos Filini
Date: Tue, 3 May 2022 12:41:22 +0200
Subject: [PATCH] Bump MSRV to 1.56
---
.github/workflows/cont_integration.yml | 4 +--
CHANGELOG.md | 1 +
README.md | 2 +-
examples/compiler.rs | 2 +-
src/blockchain/any.rs | 34 ++++++++++++++++----------
src/blockchain/compact_filters/peer.rs | 4 +--
src/blockchain/rpc.rs | 3 ---
src/database/mod.rs | 3 +--
src/descriptor/policy.rs | 6 ++---
src/wallet/export.rs | 2 +-
src/wallet/mod.rs | 4 +--
src/wallet/signer.rs | 1 +
12 files changed, 35 insertions(+), 31 deletions(-)
diff --git a/.github/workflows/cont_integration.yml b/.github/workflows/cont_integration.yml
index badcd2e6..091ba157 100644
--- a/.github/workflows/cont_integration.yml
+++ b/.github/workflows/cont_integration.yml
@@ -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
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6506d12d..5cb9f31c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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]
diff --git a/README.md b/README.md
index 8f2c7e74..10ae41c0 100644
--- a/README.md
+++ b/README.md
@@ -13,7 +13,7 @@
-
+
diff --git a/examples/compiler.rs b/examples/compiler.rs
index c3a3cb4f..8be87e81 100644
--- a/examples/compiler.rs
+++ b/examples/compiler.rs
@@ -85,7 +85,7 @@ fn main() -> Result<(), Box> {
let network = matches
.value_of("network")
- .map(|n| Network::from_str(n))
+ .map(Network::from_str)
.transpose()
.unwrap()
.unwrap_or(Network::Testnet);
diff --git a/src/blockchain/any.rs b/src/blockchain/any.rs
index 91f448b3..b6698462 100644
--- a/src/blockchain/any.rs
+++ b/src/blockchain/any.rs
@@ -34,6 +34,14 @@
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),
#[cfg(feature = "esplora")]
#[cfg_attr(docsrs, doc(cfg(feature = "esplora")))]
/// Esplora client
- Esplora(esplora::EsploraBlockchain),
+ Esplora(Box),
#[cfg(feature = "compact_filters")]
#[cfg_attr(docsrs, doc(cfg(feature = "compact_filters")))]
/// Compact filters client
- CompactFilters(compact_filters::CompactFiltersBlockchain),
+ CompactFilters(Box),
#[cfg(feature = "rpc")]
#[cfg_attr(docsrs, doc(cfg(feature = "rpc")))]
/// RPC client
- Rpc(rpc::RpcBlockchain),
+ Rpc(Box),
}
#[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)?))
}
})
}
diff --git a/src/blockchain/compact_filters/peer.rs b/src/blockchain/compact_filters/peer.rs
index f415d285..a8d65aa9 100644
--- a/src/blockchain/compact_filters/peer.rs
+++ b/src/blockchain/compact_filters/peer.rs
@@ -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>,
responses: Arc>,
diff --git a/src/blockchain/rpc.rs b/src/blockchain/rpc.rs
index e8da3451..78d166e3 100644
--- a/src/blockchain/rpc.rs
+++ b/src/blockchain/rpc.rs
@@ -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,
/// 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,
diff --git a/src/database/mod.rs b/src/database/mod.rs
index 8141ede4..e31d3a1e 100644
--- a/src/database/mod.rs
+++ b/src/database/mod.rs
@@ -200,8 +200,7 @@ pub(crate) trait DatabaseUtils: Database {
D: FnOnce() -> Result