Skip to content

Commit

Permalink
Fixup some nightly clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
romanz committed Jul 20, 2021
1 parent 3bf5e5c commit 2510531
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 26 deletions.
8 changes: 4 additions & 4 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl ResolvAddr {
/// Resolves the address.
fn resolve(self) -> std::result::Result<SocketAddr, AddressError> {
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 }),
}
}
Expand Down Expand Up @@ -109,9 +109,9 @@ impl ::configure_me::parse_arg::ParseArgFromStr for BitcoinNetwork {
}
}

impl Into<Network> for BitcoinNetwork {
fn into(self) -> Network {
self.0
impl From<BitcoinNetwork> for Network {
fn from(network: BitcoinNetwork) -> Network {
network.0
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/electrum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
})
}
Expand Down
14 changes: 7 additions & 7 deletions src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,27 +112,27 @@ impl Index {
&self.chain
}

pub(crate) fn filter_by_txid<'a>(&'a self, txid: Txid) -> impl Iterator<Item = BlockHash> + 'a {
pub(crate) fn filter_by_txid(&self, txid: Txid) -> impl Iterator<Item = BlockHash> + '_ {
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<Item = BlockHash> + 'a {
) -> impl Iterator<Item = BlockHash> + '_ {
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<Item = BlockHash> + 'a {
) -> impl Iterator<Item = BlockHash> + '_ {
self.store
.iter_spending(SpendingPrefixRow::scan_prefix(outpoint))
.map(|row| SpendingPrefixRow::from_db_row(&row).height())
Expand Down
8 changes: 4 additions & 4 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl Peer {
fn tip_receiver(config: &Config) -> Result<Receiver<BlockHash>> {
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 {
Expand All @@ -80,7 +80,7 @@ fn tip_receiver(config: &Config) -> Result<Receiver<BlockHash>> {

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();
Expand Down Expand Up @@ -118,7 +118,7 @@ pub fn run(config: &Config, mut rpc: Rpc) -> Result<()> {
fn notify_peers(rpc: &Rpc, peers: HashMap<usize, Peer>) -> HashMap<usize, Peer> {
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);
Expand Down Expand Up @@ -173,7 +173,7 @@ fn handle_event(rpc: &Rpc, peers: &mut HashMap<usize, Peer>, 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])
}

Expand Down
8 changes: 4 additions & 4 deletions src/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl TxEntry {
}
}

fn funding<'a>(&'a self) -> impl Iterator<Item = OutPoint> + 'a {
fn funding(&self) -> impl Iterator<Item = OutPoint> + '_ {
make_outpoints(&self.txid, &self.outputs)
}
}
Expand Down Expand Up @@ -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()
Expand All @@ -283,7 +283,7 @@ impl Status {
self.for_new_blocks(spending_blockhashes, daemon, |blockhash, block| {
let txids: Vec<Txid> = 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;
}
Expand Down Expand Up @@ -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());
Expand Down
4 changes: 2 additions & 2 deletions src/tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -54,7 +54,7 @@ impl Tracker {

pub fn get_history(&self, status: &Status) -> impl Iterator<Item = Value> {
let confirmed = status
.get_confirmed(&self.index.chain())
.get_confirmed(self.index.chain())
.into_iter()
.map(|entry| entry.value());
let mempool = status
Expand Down
8 changes: 4 additions & 4 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand All @@ -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")
}
}

Expand Down

0 comments on commit 2510531

Please sign in to comment.