diff --git a/src/config.rs b/src/config.rs index 41a81a7f4..ff5ab0957 100644 --- a/src/config.rs +++ b/src/config.rs @@ -71,7 +71,7 @@ impl ResolvAddr { /// Resolves the address. fn resolve(self) -> std::result::Result { match self.0.to_socket_addrs() { - Ok(mut iter) => iter.next().ok_or_else(|| AddressError::NoAddrError(self.0)), + Ok(mut iter) => iter.next().ok_or(AddressError::NoAddrError(self.0)), Err(err) => Err(AddressError::ResolvError { addr: self.0, err }), } } @@ -109,9 +109,9 @@ impl ::configure_me::parse_arg::ParseArgFromStr for BitcoinNetwork { } } -impl Into for BitcoinNetwork { - fn into(self) -> Network { - self.0 +impl From for Network { + fn from(network: BitcoinNetwork) -> Network { + network.0 } } diff --git a/src/electrum.rs b/src/electrum.rs index 5dae7992b..ba182bb07 100644 --- a/src/electrum.rs +++ b/src/electrum.rs @@ -128,7 +128,7 @@ impl Rpc { tracker, cache: Cache::default(), rpc_duration, - daemon: Daemon::connect(&config)?, + daemon: Daemon::connect(config)?, banner: config.server_banner.clone(), }) } diff --git a/src/index.rs b/src/index.rs index 730c66d68..ade077785 100644 --- a/src/index.rs +++ b/src/index.rs @@ -112,27 +112,27 @@ impl Index { &self.chain } - pub(crate) fn filter_by_txid<'a>(&'a self, txid: Txid) -> impl Iterator + 'a { + pub(crate) fn filter_by_txid(&self, txid: Txid) -> impl Iterator + '_ { self.store .iter_txid(TxidRow::scan_prefix(txid)) .map(|row| TxidRow::from_db_row(&row).height()) .filter_map(move |height| self.chain.get_block_hash(height)) } - pub(crate) fn filter_by_funding<'a>( - &'a self, + pub(crate) fn filter_by_funding( + &self, scripthash: ScriptHash, - ) -> impl Iterator + 'a { + ) -> impl Iterator + '_ { self.store .iter_funding(ScriptHashRow::scan_prefix(scripthash)) .map(|row| ScriptHashRow::from_db_row(&row).height()) .filter_map(move |height| self.chain.get_block_hash(height)) } - pub(crate) fn filter_by_spending<'a>( - &'a self, + pub(crate) fn filter_by_spending( + &self, outpoint: OutPoint, - ) -> impl Iterator + 'a { + ) -> impl Iterator + '_ { self.store .iter_spending(SpendingPrefixRow::scan_prefix(outpoint)) .map(|row| SpendingPrefixRow::from_db_row(&row).height()) diff --git a/src/server.rs b/src/server.rs index 5d479bb2f..4dd04605d 100644 --- a/src/server.rs +++ b/src/server.rs @@ -64,7 +64,7 @@ impl Peer { fn tip_receiver(config: &Config) -> Result> { let duration = u64::try_from(config.wait_duration.as_millis()).unwrap(); let (tip_tx, tip_rx) = bounded(0); - let rpc = rpc_connect(&config)?; + let rpc = rpc_connect(config)?; use crossbeam_channel::TrySendError; spawn("tip_loop", move || loop { @@ -80,7 +80,7 @@ fn tip_receiver(config: &Config) -> Result> { pub fn run(config: &Config, mut rpc: Rpc) -> Result<()> { let listener = TcpListener::bind(config.electrum_rpc_addr)?; - let tip_rx = tip_receiver(&config)?; + let tip_rx = tip_receiver(config)?; info!("serving Electrum RPC on {}", listener.local_addr()?); let (server_tx, server_rx) = unbounded(); @@ -118,7 +118,7 @@ pub fn run(config: &Config, mut rpc: Rpc) -> Result<()> { fn notify_peers(rpc: &Rpc, peers: HashMap) -> HashMap { peers .into_par_iter() - .filter_map(|(_, mut peer)| match notify_peer(&rpc, &mut peer) { + .filter_map(|(_, mut peer)| match notify_peer(rpc, &mut peer) { Ok(()) => Some((peer.id, peer)), Err(e) => { error!("failed to notify peer {}: {}", peer.id, e); @@ -173,7 +173,7 @@ fn handle_event(rpc: &Rpc, peers: &mut HashMap, event: Event) { } fn handle_request(rpc: &Rpc, peer: &mut Peer, line: &str) -> Result<()> { - let response = rpc.handle_request(&mut peer.client, &line); + let response = rpc.handle_request(&mut peer.client, line); peer.send(vec![response]) } diff --git a/src/status.rs b/src/status.rs index 60e607a43..d2bd588c5 100644 --- a/src/status.rs +++ b/src/status.rs @@ -40,7 +40,7 @@ impl TxEntry { } } - fn funding<'a>(&'a self) -> impl Iterator + 'a { + fn funding(&self) -> impl Iterator + '_ { make_outpoints(&self.txid, &self.outputs) } } @@ -267,7 +267,7 @@ impl Status { } cache.add_tx(*txid, move || tx); cache.add_proof(blockhash, *txid, || Proof::create(&txids, pos)); - outpoints.extend(make_outpoints(&txid, &funding_outputs)); + outpoints.extend(make_outpoints(txid, &funding_outputs)); result .entry(blockhash) .or_default() @@ -283,7 +283,7 @@ impl Status { self.for_new_blocks(spending_blockhashes, daemon, |blockhash, block| { let txids: Vec = block.txdata.iter().map(|tx| tx.txid()).collect(); for (pos, (tx, txid)) in block.txdata.into_iter().zip(txids.iter()).enumerate() { - let spent_outpoints = filter_inputs(&tx, &outpoints); + let spent_outpoints = filter_inputs(&tx, outpoints); if spent_outpoints.is_empty() { continue; } @@ -330,7 +330,7 @@ impl Status { .iter() .flat_map(|outpoint| mempool.filter_by_spending(outpoint)) { - let spent_outpoints = filter_inputs(&entry.tx, &outpoints); + let spent_outpoints = filter_inputs(&entry.tx, outpoints); assert!(!spent_outpoints.is_empty()); result.entry(entry.txid).or_default().spent = spent_outpoints; cache.add_tx(entry.txid, || entry.tx.clone()); diff --git a/src/tracker.rs b/src/tracker.rs index 0e92095c7..6574b4b11 100644 --- a/src/tracker.rs +++ b/src/tracker.rs @@ -45,7 +45,7 @@ impl Tracker { } pub(crate) fn fees_histogram(&self) -> &Histogram { - &self.mempool.fees_histogram() + self.mempool.fees_histogram() } pub(crate) fn metrics(&self) -> &Metrics { @@ -54,7 +54,7 @@ impl Tracker { pub fn get_history(&self, status: &Status) -> impl Iterator { let confirmed = status - .get_confirmed(&self.index.chain()) + .get_confirmed(self.index.chain()) .into_iter() .map(|entry| entry.value()); let mempool = status diff --git a/src/types.rs b/src/types.rs index 480f014e9..715161821 100644 --- a/src/types.rs +++ b/src/types.rs @@ -93,7 +93,7 @@ impl ScriptHashRow { } pub(crate) fn from_db_row(row: &[u8]) -> Self { - deserialize(&row).expect("bad ScriptHashRow") + deserialize(row).expect("bad ScriptHashRow") } pub(crate) fn height(&self) -> usize { @@ -154,7 +154,7 @@ impl SpendingPrefixRow { } pub(crate) fn from_db_row(row: &[u8]) -> Self { - deserialize(&row).expect("bad SpendingPrefixRow") + deserialize(row).expect("bad SpendingPrefixRow") } pub(crate) fn height(&self) -> usize { @@ -202,7 +202,7 @@ impl TxidRow { } pub(crate) fn from_db_row(row: &[u8]) -> Self { - deserialize(&row).expect("bad TxidRow") + deserialize(row).expect("bad TxidRow") } pub(crate) fn height(&self) -> usize { @@ -229,7 +229,7 @@ impl HeaderRow { } pub(crate) fn from_db_row(row: &[u8]) -> Self { - deserialize(&row).expect("bad HeaderRow") + deserialize(row).expect("bad HeaderRow") } }