chore: fix clippy errors and set msrv to 1.63
This commit is contained in:
parent
84f4f609b9
commit
e7af332684
1
clippy.toml
Normal file
1
clippy.toml
Normal file
@ -0,0 +1 @@
|
||||
msrv="1.63.0"
|
||||
@ -16,6 +16,7 @@ use crate::types::{Call, Param, ToElectrumScriptHash};
|
||||
/// [`Client`](../client/struct.Client.html), like
|
||||
/// [`batch_script_get_balance`](../client/struct.Client.html#method.batch_script_get_balance) to ask the
|
||||
/// server for the balance of multiple scripts with a single request.
|
||||
#[derive(Default)]
|
||||
pub struct Batch {
|
||||
calls: Vec<Call>,
|
||||
}
|
||||
@ -107,9 +108,3 @@ impl<'a> std::iter::Iterator for BatchIter<'a> {
|
||||
val
|
||||
}
|
||||
}
|
||||
|
||||
impl std::default::Default for Batch {
|
||||
fn default() -> Self {
|
||||
Batch { calls: Vec::new() }
|
||||
}
|
||||
}
|
||||
|
||||
@ -353,7 +353,7 @@ mod tests {
|
||||
fn more_failed_attempts_than_retries_means_exhausted() {
|
||||
let exhausted = retries_exhausted(10, 5);
|
||||
|
||||
assert_eq!(exhausted, true)
|
||||
assert!(exhausted)
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -362,21 +362,21 @@ mod tests {
|
||||
|
||||
let exhausted = retries_exhausted(failed_attempts, u8::MAX);
|
||||
|
||||
assert_eq!(exhausted, true)
|
||||
assert!(exhausted)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn less_failed_attempts_means_not_exhausted() {
|
||||
let exhausted = retries_exhausted(2, 5);
|
||||
|
||||
assert_eq!(exhausted, false)
|
||||
assert!(!exhausted)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn attempts_equals_retries_means_not_exhausted_yet() {
|
||||
let exhausted = retries_exhausted(2, 2);
|
||||
|
||||
assert_eq!(exhausted, false)
|
||||
assert!(!exhausted)
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -408,7 +408,7 @@ mod tests {
|
||||
sender.send(()).unwrap();
|
||||
|
||||
for _stream in listener.incoming() {
|
||||
loop {}
|
||||
std::thread::sleep(Duration::from_secs(60))
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -83,7 +83,7 @@ pub trait ToSocketAddrsDomain: ToSocketAddrs {
|
||||
|
||||
impl ToSocketAddrsDomain for &str {
|
||||
fn domain(&self) -> Option<&str> {
|
||||
self.splitn(2, ':').next()
|
||||
self.split(':').next()
|
||||
}
|
||||
}
|
||||
|
||||
@ -406,11 +406,11 @@ impl RawClient<ElectrumSslStream> {
|
||||
socket_addr.domain().ok_or(Error::MissingDomain)?;
|
||||
|
||||
let store = webpki_roots::TLS_SERVER_ROOTS
|
||||
.into_iter()
|
||||
.iter()
|
||||
.map(|t| TrustAnchor {
|
||||
subject: Der::from_slice(t.subject),
|
||||
subject_public_key_info: Der::from_slice(t.spki),
|
||||
name_constraints: t.name_constraints.map(|nc| Der::from_slice(nc)),
|
||||
name_constraints: t.name_constraints.map(Der::from_slice),
|
||||
})
|
||||
.collect::<RootCertStore>();
|
||||
|
||||
@ -605,7 +605,7 @@ impl<S: Read + Write> RawClient<S> {
|
||||
// No id, that's probably a notification.
|
||||
let mut resp = resp;
|
||||
|
||||
if let Some(ref method) = resp["method"].take().as_str() {
|
||||
if let Some(method) = resp["method"].take().as_str() {
|
||||
self.handle_notification(method, resp["params"].take())?;
|
||||
} else {
|
||||
warn!("Unexpected response: {:?}", resp);
|
||||
@ -722,7 +722,7 @@ impl<S: Read + Write> RawClient<S> {
|
||||
) -> Result<serde_json::Value, Error> {
|
||||
let req = Request::new_id(
|
||||
self.last_id.fetch_add(1, Ordering::SeqCst),
|
||||
&method_name,
|
||||
method_name,
|
||||
params,
|
||||
);
|
||||
let result = self.call(req)?;
|
||||
@ -763,7 +763,7 @@ impl<T: Read + Write> ElectrumApi for RawClient<T> {
|
||||
for (method, params) in batch.iter() {
|
||||
let req = Request::new_id(
|
||||
self.last_id.fetch_add(1, Ordering::SeqCst),
|
||||
&method,
|
||||
method,
|
||||
params.to_vec(),
|
||||
);
|
||||
missing_responses.insert(req.id);
|
||||
@ -804,7 +804,7 @@ impl<T: Read + Write> ElectrumApi for RawClient<T> {
|
||||
};
|
||||
}
|
||||
|
||||
Ok(answers.into_iter().map(|(_, r)| r).collect())
|
||||
Ok(answers.into_values().collect())
|
||||
}
|
||||
|
||||
fn block_headers_subscribe_raw(&self) -> Result<RawHeaderNotification, Error> {
|
||||
@ -1128,7 +1128,7 @@ mod test {
|
||||
use crate::utils;
|
||||
|
||||
use super::RawClient;
|
||||
use api::ElectrumApi;
|
||||
use crate::api::ElectrumApi;
|
||||
|
||||
fn get_test_server() -> String {
|
||||
std::env::var("TEST_ELECTRUM_SERVER").unwrap_or("electrum.blockstream.info:50001".into())
|
||||
@ -1426,7 +1426,7 @@ mod test {
|
||||
|
||||
#[test]
|
||||
fn test_raw_call() {
|
||||
use types::Param;
|
||||
use crate::types::Param;
|
||||
|
||||
let client = RawClient::new(get_test_server(), None).unwrap();
|
||||
|
||||
|
||||
@ -109,7 +109,7 @@ impl Socks4Stream {
|
||||
let _ = packet.write_u32::<BigEndian>(Ipv4Addr::new(0, 0, 0, 1).into());
|
||||
let _ = packet.write_all(userid.as_bytes());
|
||||
let _ = packet.write_u8(0);
|
||||
let _ = packet.extend(host.as_bytes());
|
||||
packet.extend(host.as_bytes());
|
||||
let _ = packet.write_u8(0);
|
||||
}
|
||||
}
|
||||
@ -118,8 +118,8 @@ impl Socks4Stream {
|
||||
let proxy_addr = read_response(&mut socket)?;
|
||||
|
||||
Ok(Socks4Stream {
|
||||
socket: socket,
|
||||
proxy_addr: proxy_addr,
|
||||
socket,
|
||||
proxy_addr,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@ -110,7 +110,7 @@ fn write_addr(mut packet: &mut [u8], target: &TargetAddr) -> io::Result<usize> {
|
||||
}
|
||||
TargetAddr::Domain(ref domain, port) => {
|
||||
packet.write_u8(3).unwrap();
|
||||
if domain.len() > u8::max_value() as usize {
|
||||
if domain.len() > u8::MAX as usize {
|
||||
return Err(io::Error::new(
|
||||
io::ErrorKind::InvalidInput,
|
||||
"domain name too long",
|
||||
@ -144,11 +144,7 @@ impl<'a> Authentication<'a> {
|
||||
}
|
||||
|
||||
fn is_no_auth(&self) -> bool {
|
||||
if let Authentication::None = *self {
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
matches!(*self, Authentication::None)
|
||||
}
|
||||
}
|
||||
|
||||
@ -258,8 +254,8 @@ impl Socks5Stream {
|
||||
let proxy_addr = read_response(&mut socket)?;
|
||||
|
||||
Ok(Socks5Stream {
|
||||
socket: socket,
|
||||
proxy_addr: proxy_addr,
|
||||
socket,
|
||||
proxy_addr,
|
||||
})
|
||||
}
|
||||
|
||||
@ -268,13 +264,13 @@ impl Socks5Stream {
|
||||
username: &str,
|
||||
password: &str,
|
||||
) -> io::Result<()> {
|
||||
if username.len() < 1 || username.len() > 255 {
|
||||
if username.is_empty() || username.len() > 255 {
|
||||
return Err(io::Error::new(
|
||||
io::ErrorKind::InvalidInput,
|
||||
"invalid username",
|
||||
));
|
||||
};
|
||||
if password.len() < 1 || password.len() > 255 {
|
||||
if password.is_empty() || password.len() > 255 {
|
||||
return Err(io::Error::new(
|
||||
io::ErrorKind::InvalidInput,
|
||||
"invalid password",
|
||||
@ -475,8 +471,8 @@ impl Socks5Datagram {
|
||||
socket.connect(&stream.proxy_addr)?;
|
||||
|
||||
Ok(Socks5Datagram {
|
||||
socket: socket,
|
||||
stream: stream,
|
||||
socket,
|
||||
stream,
|
||||
})
|
||||
}
|
||||
|
||||
@ -528,7 +524,7 @@ impl Socks5Datagram {
|
||||
unsafe {
|
||||
ptr::copy(
|
||||
buf.as_ptr(),
|
||||
buf.as_mut_ptr().offset(header.len() as isize),
|
||||
buf.as_mut_ptr().add(header.len()),
|
||||
overflow,
|
||||
);
|
||||
}
|
||||
|
||||
@ -87,7 +87,7 @@ impl From<[u8; 32]> for Hex32Bytes {
|
||||
}
|
||||
|
||||
impl Hex32Bytes {
|
||||
pub(crate) fn to_hex(&self) -> String {
|
||||
pub(crate) fn to_hex(self) -> String {
|
||||
self.0.to_lower_hex_string()
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user