Skip to content

Commit

Permalink
Merge #815: Bump CI Rust stable version to 1.65.0
Browse files Browse the repository at this point in the history
fb76c9e ci: bump rust stable version to 1.65.0 (Yuki Kishimoto)
3a782b3 Fix Clippy Rust 1.65 (Yuki Kishimoto)

Pull request description:

  ### Description

  * Fix clippy for Rust 1.65.0
  * Bump CI Rust stable version to 1.65.0

  ### 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

ACKs for top commit:
  rajarshimaitra:
    ReACK fb76c9e

Tree-SHA512: 2f27915895cb203842831e525cc9efe0503269df07b7e58ab2a587e2991decf2990cb48abe8209c89cec5706a1d9c72387da532b70979ec100b5eed469051136
  • Loading branch information
notmandatory committed Jan 24, 2023
2 parents eac739d + fb76c9e commit 0cce1ce
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cont_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
strategy:
matrix:
rust:
- version: 1.60.0 # STABLE
- version: 1.65.0 # STABLE
clippy: true
- version: 1.56.1 # MSRV
features:
Expand Down
4 changes: 2 additions & 2 deletions src/blockchain/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ impl GetBlockHash for AnyBlockchain {
impl WalletSync for AnyBlockchain {
fn wallet_sync<D: BatchDatabase>(
&self,
database: &mut D,
database: &RefCell<D>,
progress_update: Box<dyn Progress>,
) -> Result<(), Error> {
maybe_await!(impl_inner_method!(
Expand All @@ -144,7 +144,7 @@ impl WalletSync for AnyBlockchain {

fn wallet_setup<D: BatchDatabase>(
&self,
database: &mut D,
database: &RefCell<D>,
progress_update: Box<dyn Progress>,
) -> Result<(), Error> {
maybe_await!(impl_inner_method!(
Expand Down
6 changes: 5 additions & 1 deletion src/blockchain/compact_filters/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
use std::collections::HashSet;
use std::fmt;
use std::ops::DerefMut;
use std::path::Path;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::{Arc, Mutex};
Expand Down Expand Up @@ -274,7 +275,7 @@ impl WalletSync for CompactFiltersBlockchain {
#[allow(clippy::mutex_atomic)] // Mutex is easier to understand than a CAS loop.
fn wallet_setup<D: BatchDatabase>(
&self,
database: &mut D,
database: &RefCell<D>,
progress_update: Box<dyn Progress>,
) -> Result<(), Error> {
let first_peer = &self.peers[0];
Expand Down Expand Up @@ -322,6 +323,9 @@ impl WalletSync for CompactFiltersBlockchain {

cf_sync.prepare_sync(Arc::clone(first_peer))?;

let mut database = database.borrow_mut();
let database = database.deref_mut();

let all_scripts = Arc::new(
database
.iter_script_pubkeys(None)?
Expand Down
6 changes: 3 additions & 3 deletions src/blockchain/compact_filters/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ impl ChainStore<Full> {
batch.put_cf(
cf_handle,
StoreEntry::BlockHeaderIndex(Some(genesis.block_hash())).get_key(),
&0usize.to_be_bytes(),
0usize.to_be_bytes(),
);
store.write(batch)?;
}
Expand Down Expand Up @@ -302,7 +302,7 @@ impl ChainStore<Full> {
batch.put_cf(
new_cf_handle,
StoreEntry::BlockHeaderIndex(Some(header.block_hash())).get_key(),
&from.to_be_bytes(),
from.to_be_bytes(),
);
batch.put_cf(
new_cf_handle,
Expand Down Expand Up @@ -584,7 +584,7 @@ impl<T: StoreType> ChainStore<T> {
batch.put_cf(
cf_handle,
StoreEntry::BlockHeaderIndex(Some(header.block_hash())).get_key(),
&(height).to_be_bytes(),
(height).to_be_bytes(),
);
batch.put_cf(
cf_handle,
Expand Down
6 changes: 4 additions & 2 deletions src/blockchain/electrum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
//! ```
use std::collections::{HashMap, HashSet};
use std::ops::Deref;
use std::ops::{Deref, DerefMut};

#[allow(unused_imports)]
use log::{debug, error, info, trace};
Expand Down Expand Up @@ -117,9 +117,11 @@ impl GetBlockHash for ElectrumBlockchain {
impl WalletSync for ElectrumBlockchain {
fn wallet_setup<D: BatchDatabase>(
&self,
database: &mut D,
database: &RefCell<D>,
_progress_update: Box<dyn Progress>,
) -> Result<(), Error> {
let mut database = database.borrow_mut();
let database = database.deref_mut();
let mut request = script_sync::start(database, self.stop_gap)?;
let mut block_times = HashMap::<u32, u32>::new();
let mut txid_to_height = HashMap::<Txid, u32>::new();
Expand Down
6 changes: 4 additions & 2 deletions src/blockchain/esplora/async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
//! Esplora by way of `reqwest` HTTP client.
use std::collections::{HashMap, HashSet};
use std::ops::Deref;
use std::ops::{Deref, DerefMut};

use bitcoin::{Transaction, Txid};

Expand Down Expand Up @@ -135,10 +135,12 @@ impl GetBlockHash for EsploraBlockchain {
impl WalletSync for EsploraBlockchain {
fn wallet_setup<D: BatchDatabase>(
&self,
database: &mut D,
database: &RefCell<D>,
_progress_update: Box<dyn Progress>,
) -> Result<(), Error> {
use crate::blockchain::script_sync::Request;
let mut database = database.borrow_mut();
let database = database.deref_mut();
let mut request = script_sync::start(database, self.stop_gap)?;
let mut tx_index: HashMap<Txid, Tx> = HashMap::new();

Expand Down
5 changes: 4 additions & 1 deletion src/blockchain/esplora/blocking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
//! Esplora by way of `ureq` HTTP client.
use std::collections::{HashMap, HashSet};
use std::ops::DerefMut;

#[allow(unused_imports)]
use log::{debug, error, info, trace};
Expand Down Expand Up @@ -117,10 +118,12 @@ impl GetBlockHash for EsploraBlockchain {
impl WalletSync for EsploraBlockchain {
fn wallet_setup<D: BatchDatabase>(
&self,
database: &mut D,
database: &RefCell<D>,
_progress_update: Box<dyn Progress>,
) -> Result<(), Error> {
use crate::blockchain::script_sync::Request;
let mut database = database.borrow_mut();
let database = database.deref_mut();
let mut request = script_sync::start(database, self.stop_gap)?;
let mut tx_index: HashMap<Txid, Tx> = HashMap::new();
let batch_update = loop {
Expand Down
9 changes: 5 additions & 4 deletions src/blockchain/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
//! [Compact Filters/Neutrino](crate::blockchain::compact_filters), along with a generalized trait
//! [`Blockchain`] that can be implemented to build customized backends.
use std::cell::RefCell;
use std::collections::HashSet;
use std::ops::Deref;
use std::sync::mpsc::{channel, Receiver, Sender};
Expand Down Expand Up @@ -133,7 +134,7 @@ pub trait WalletSync {
/// Populate the internal database with transactions and UTXOs
fn wallet_setup<D: BatchDatabase>(
&self,
database: &mut D,
database: &RefCell<D>,
progress_update: Box<dyn Progress>,
) -> Result<(), Error>;

Expand All @@ -156,7 +157,7 @@ pub trait WalletSync {
/// [`BatchOperations::del_utxo`]: crate::database::BatchOperations::del_utxo
fn wallet_sync<D: BatchDatabase>(
&self,
database: &mut D,
database: &RefCell<D>,
progress_update: Box<dyn Progress>,
) -> Result<(), Error> {
maybe_await!(self.wallet_setup(database, progress_update))
Expand Down Expand Up @@ -377,15 +378,15 @@ impl<T: GetBlockHash> GetBlockHash for Arc<T> {
impl<T: WalletSync> WalletSync for Arc<T> {
fn wallet_setup<D: BatchDatabase>(
&self,
database: &mut D,
database: &RefCell<D>,
progress_update: Box<dyn Progress>,
) -> Result<(), Error> {
maybe_await!(self.deref().wallet_setup(database, progress_update))
}

fn wallet_sync<D: BatchDatabase>(
&self,
database: &mut D,
database: &RefCell<D>,
progress_update: Box<dyn Progress>,
) -> Result<(), Error> {
maybe_await!(self.deref().wallet_sync(database, progress_update))
Expand Down
7 changes: 5 additions & 2 deletions src/blockchain/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ use bitcoincore_rpc::Auth as RpcAuth;
use bitcoincore_rpc::{Client, RpcApi};
use log::{debug, info};
use serde::{Deserialize, Serialize};
use std::cell::RefCell;
use std::collections::{HashMap, HashSet};
use std::ops::Deref;
use std::ops::{Deref, DerefMut};
use std::path::PathBuf;
use std::thread;
use std::time::Duration;
Expand Down Expand Up @@ -192,10 +193,12 @@ impl GetBlockHash for RpcBlockchain {
}

impl WalletSync for RpcBlockchain {
fn wallet_setup<D>(&self, db: &mut D, prog: Box<dyn Progress>) -> Result<(), Error>
fn wallet_setup<D>(&self, db: &RefCell<D>, prog: Box<dyn Progress>) -> Result<(), Error>
where
D: BatchDatabase,
{
let mut db = db.borrow_mut();
let db = db.deref_mut();
let batch = DbState::new(db, &self.sync_params, &*prog)?
.sync_with_core(&self.client, self.is_descriptors)?
.as_db_batch()?;
Expand Down
4 changes: 2 additions & 2 deletions src/descriptor/policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1197,7 +1197,7 @@ mod test {
.unwrap();

assert_matches!(&policy.item, EcdsaSignature(PkOrF::Fingerprint(f)) if f == &fingerprint);
assert_matches!(&policy.contribution, Satisfaction::Complete {condition} if condition.csv == None && condition.timelock == None);
assert_matches!(&policy.contribution, Satisfaction::Complete {condition} if condition.csv.is_none() && condition.timelock.is_none());
}

// 2 pub keys descriptor, required 2 prv keys
Expand Down Expand Up @@ -1346,7 +1346,7 @@ mod test {
.unwrap();

assert_matches!(policy.item, EcdsaSignature(PkOrF::Fingerprint(f)) if f == fingerprint);
assert_matches!(policy.contribution, Satisfaction::Complete {condition} if condition.csv == None && condition.timelock == None);
assert_matches!(policy.contribution, Satisfaction::Complete {condition} if condition.csv.is_none() && condition.timelock.is_none());
}

// single key, 1 prv and 1 pub key descriptor, required 1 prv keys
Expand Down
15 changes: 6 additions & 9 deletions src/wallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use std::cell::RefCell;
use std::collections::HashMap;
use std::collections::{BTreeMap, HashSet};
use std::fmt;
use std::ops::{Deref, DerefMut};
use std::ops::Deref;
use std::str::FromStr;
use std::sync::Arc;

Expand Down Expand Up @@ -1719,14 +1719,11 @@ where
let max_rounds = if has_wildcard { 100 } else { 1 };

for _ in 0..max_rounds {
let sync_res =
if run_setup {
maybe_await!(blockchain
.wallet_setup(self.database.borrow_mut().deref_mut(), new_progress()))
} else {
maybe_await!(blockchain
.wallet_sync(self.database.borrow_mut().deref_mut(), new_progress()))
};
let sync_res = if run_setup {
maybe_await!(blockchain.wallet_setup(&self.database, new_progress()))
} else {
maybe_await!(blockchain.wallet_sync(&self.database, new_progress()))
};

// If the error is the special `MissingCachedScripts` error, we return the number of
// scripts we should ensure cached.
Expand Down

0 comments on commit 0cce1ce

Please sign in to comment.