mirror of
https://github.com/romanz/electrs.git
synced 2025-02-24 06:57:53 +01:00
Fix clippy warnings
This commit is contained in:
parent
d4f542b5e1
commit
521914a853
12 changed files with 13 additions and 27 deletions
|
@ -1,7 +1,6 @@
|
|||
use bitcoin::blockdata::block::Block;
|
||||
use bitcoin::consensus::encode::{deserialize, Decodable};
|
||||
use bitcoin::hash_types::BlockHash;
|
||||
use libc;
|
||||
use std::collections::HashSet;
|
||||
use std::fs;
|
||||
use std::io::Cursor;
|
||||
|
|
|
@ -128,12 +128,9 @@ impl TransactionCache {
|
|||
where
|
||||
F: FnOnce() -> Result<Vec<u8>>,
|
||||
{
|
||||
match self.map.lock().unwrap().get(txid) {
|
||||
Some(serialized_txn) => {
|
||||
if let Some(serialized_txn) = self.map.lock().unwrap().get(txid) {
|
||||
return Ok(deserialize(&serialized_txn).chain_err(|| "failed to parse cached tx")?);
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
let serialized_txn = load_txn_func()?;
|
||||
let txn = deserialize(&serialized_txn).chain_err(|| "failed to parse serialized tx")?;
|
||||
let byte_size = 32 /* key (hash size) */ + serialized_txn.len();
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use bitcoin::network::constants::Network;
|
||||
use dirs::home_dir;
|
||||
use num_cpus;
|
||||
use std::convert::TryInto;
|
||||
use std::ffi::{OsStr, OsString};
|
||||
use std::fmt;
|
||||
|
@ -11,7 +10,6 @@ use std::path::{Path, PathBuf};
|
|||
use std::str::FromStr;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
use stderrlog;
|
||||
|
||||
use crate::daemon::CookieGetter;
|
||||
use crate::errors::*;
|
||||
|
@ -235,12 +233,12 @@ impl Config {
|
|||
Network::Regtest => config.daemon_dir.push("regtest"),
|
||||
}
|
||||
|
||||
let daemon_dir = &config.daemon_dir;
|
||||
let blocks_dir = config
|
||||
.blocks_dir
|
||||
.unwrap_or(default_blocks_dir(&config.daemon_dir));
|
||||
.unwrap_or_else(|| default_blocks_dir(daemon_dir));
|
||||
|
||||
let cookie_getter =
|
||||
create_cookie_getter(config.cookie, config.cookie_file, &config.daemon_dir);
|
||||
let cookie_getter = create_cookie_getter(config.cookie, config.cookie_file, daemon_dir);
|
||||
|
||||
let mut log = stderrlog::new();
|
||||
log.verbosity(
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
use base64;
|
||||
use bitcoin::blockdata::block::{Block, BlockHeader};
|
||||
use bitcoin::blockdata::transaction::Transaction;
|
||||
use bitcoin::consensus::encode::{deserialize, serialize};
|
||||
|
@ -6,8 +5,6 @@ use bitcoin::hash_types::{BlockHash, Txid};
|
|||
use bitcoin::network::constants::Network;
|
||||
use bitcoin_hashes::hex::{FromHex, ToHex};
|
||||
use bitcoin_hashes::Hash;
|
||||
use glob;
|
||||
use hex;
|
||||
use serde_json::{from_str, from_value, Map, Value};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::io::{BufRead, BufReader, Lines, Write};
|
||||
|
@ -321,7 +318,7 @@ impl Daemon {
|
|||
signal.clone(),
|
||||
)?),
|
||||
message_id: Counter::new(),
|
||||
blocktxids_cache: blocktxids_cache,
|
||||
blocktxids_cache,
|
||||
signal: signal.clone(),
|
||||
latency: metrics.histogram_vec(
|
||||
HistogramOpts::new("electrs_daemon_rpc", "Bitcoind RPC latency (in seconds)"),
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
use bincode;
|
||||
use bitcoin::blockdata::block::{Block, BlockHeader};
|
||||
use bitcoin::blockdata::transaction::{Transaction, TxIn, TxOut};
|
||||
use bitcoin::consensus::encode::{deserialize, serialize};
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use bitcoin::blockdata::transaction::Transaction;
|
||||
use bitcoin::hash_types::Txid;
|
||||
use hex;
|
||||
use std::collections::{BTreeMap, HashMap, HashSet};
|
||||
use std::iter::FromIterator;
|
||||
use std::ops::Bound;
|
||||
|
@ -32,7 +31,7 @@ impl MempoolStore {
|
|||
let rows = index_transaction(tx, 0);
|
||||
for row in rows {
|
||||
let (key, value) = row.into_pair();
|
||||
self.map.entry(key).or_insert_with(|| vec![]).push(value);
|
||||
self.map.entry(key).or_insert_with(Vec::new).push(value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
use page_size;
|
||||
use prometheus::{self, Encoder, IntGauge};
|
||||
use std::fs;
|
||||
use std::io;
|
||||
use std::net::SocketAddr;
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
use sysconf;
|
||||
use tiny_http;
|
||||
|
||||
pub use prometheus::{
|
||||
GaugeVec, Histogram, HistogramOpts, HistogramTimer, HistogramVec, IntCounter as Counter,
|
||||
|
|
|
@ -445,7 +445,7 @@ impl Query {
|
|||
|
||||
pub fn get_best_header(&self) -> Result<HeaderEntry> {
|
||||
let last_header = self.app.index().best_header();
|
||||
Ok(last_header.chain_err(|| "no headers indexed")?.clone())
|
||||
Ok(last_header.chain_err(|| "no headers indexed")?)
|
||||
}
|
||||
|
||||
pub fn get_merkle_proof(
|
||||
|
|
|
@ -3,7 +3,6 @@ use bitcoin::consensus::encode::{deserialize, serialize};
|
|||
use bitcoin_hashes::hex::{FromHex, ToHex};
|
||||
use bitcoin_hashes::{sha256d::Hash as Sha256dHash, Hash};
|
||||
use error_chain::ChainedError;
|
||||
use hex;
|
||||
use serde_json::{from_str, Value};
|
||||
use std::collections::HashMap;
|
||||
use std::io::{BufRead, BufReader, Write};
|
||||
|
@ -206,7 +205,11 @@ impl Connection {
|
|||
hash_from_value::<Sha256dHash>(params.get(0)).chain_err(|| "bad script_hash")?;
|
||||
let status = self.query.status(&script_hash[..])?;
|
||||
let result = status.hash().map_or(Value::Null, |h| json!(hex::encode(h)));
|
||||
if let None = self.status_hashes.insert(script_hash, result.clone()) {
|
||||
if self
|
||||
.status_hashes
|
||||
.insert(script_hash, result.clone())
|
||||
.is_none()
|
||||
{
|
||||
self.stats.subscriptions.inc();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use crossbeam_channel as channel;
|
||||
use crossbeam_channel::RecvTimeoutError;
|
||||
use signal_hook;
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
use rocksdb;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use crate::util::Bytes;
|
||||
|
|
|
@ -8,7 +8,6 @@ use std::iter::FromIterator;
|
|||
use std::slice;
|
||||
use std::sync::mpsc::{channel, sync_channel, Receiver, Sender, SyncSender};
|
||||
use std::thread;
|
||||
use time;
|
||||
|
||||
pub type Bytes = Vec<u8>;
|
||||
pub type HeaderMap = HashMap<BlockHash, BlockHeader>;
|
||||
|
|
Loading…
Add table
Reference in a new issue