chore: Clippy lints and compile fixes.

This commit is contained in:
parazyd
2023-08-25 19:28:08 +02:00
parent 41631701ac
commit 2b7dd67309
8 changed files with 19 additions and 8 deletions

View File

@@ -149,7 +149,7 @@ impl Darkfid {
if let Some(sync_p2p) = &self.sync_p2p {
sync_p2p.broadcast(&tx).await;
if sync_p2p.channels().lock().await.is_empty() {
if sync_p2p.channels().await.lock().await.is_empty() {
error!("[RPC] tx.broadcast: Failed broadcasting tx, no connected channels");
return server_error(RpcError::TxBroadcastFail, id, None)
}

View File

@@ -144,7 +144,7 @@ impl Darkfid {
}
self.sync_p2p.broadcast(&tx).await;
if self.sync_p2p.channels().lock().await.is_empty() {
if self.sync_p2p.channels().await.lock().await.is_empty() {
error!(target: "darkfid::rpc::tx_broadcast", "Failed broadcasting tx, no connected channels");
return server_error(RpcError::TxBroadcastFail, id, None)
}

View File

@@ -31,7 +31,7 @@ pub async fn sync_task(node: &Darkfid) -> Result<()> {
info!(target: "darkfid::task::sync_task", "Starting blockchain sync...");
// Block until at least node is connected to at least one peer
loop {
if !node.sync_p2p.channels().lock().await.is_empty() {
if !node.sync_p2p.channels().await.lock().await.is_empty() {
break
}
warn!(target: "darkfid::task::sync_task", "Node is not connected to other nodes, waiting to retry...");

View File

@@ -319,7 +319,7 @@ async fn fetch_file_task(fud: Arc<Fud>, executor: Arc<Executor<'_>>) -> Result<(
let session_weak = Arc::downgrade(&fud.p2p.session_outbound().await);
info!("Connecting to {} to fetch {}", peer, file_hash);
let connector = Connector::new(fud.p2p.settings(), Arc::new(session_weak));
let connector = Connector::new(fud.p2p.settings(), session_weak);
match connector.connect(peer).await {
Ok((url, channel)) => {
let proto_ver = ProtocolVersion::new(
@@ -426,7 +426,7 @@ async fn fetch_chunk_task(fud: Arc<Fud>, executor: Arc<Executor<'_>>) -> Result<
let session_weak = Arc::downgrade(&fud.p2p.session_outbound().await);
info!("Connecting to {} to fetch {}", peer, chunk_hash);
let connector = Connector::new(fud.p2p.settings(), Arc::new(session_weak));
let connector = Connector::new(fud.p2p.settings(), session_weak);
match connector.connect(peer).await {
Ok((url, channel)) => {
let proto_ver = ProtocolVersion::new(

View File

@@ -158,7 +158,7 @@ impl Lilith {
let session_out = p2p_.session_outbound().await;
let session_weak = Arc::downgrade(&p2p_.session_outbound().await);
let connector = Connector::new(p2p_.settings(), Arc::new(session_weak));
let connector = Connector::new(p2p_.settings(), session_weak);
debug!(target: "lilith", "Connecting to {}", host);
match connector.connect(host).await {
Ok((_url, channel)) => {

View File

@@ -574,8 +574,7 @@ impl PeerDiscovery {
let wakeup_end = Instant::now();
let epsilon = Duration::from_millis(200);
let sleep_was_instant = wakeup_end - wakeup_start <= epsilon;
sleep_was_instant
wakeup_end - wakeup_start <= epsilon
}
fn notify(&self) {

View File

@@ -72,6 +72,12 @@ impl CondVar {
}
}
impl Default for CondVar {
fn default() -> Self {
Self::new()
}
}
pub struct CondVarWait<'a> {
state: &'a Mutex<CondVarState>,
}

View File

@@ -91,3 +91,9 @@ impl<Parent> LazyWeak<Parent> {
self.0.get().unwrap().upgrade().unwrap()
}
}
impl<Parent> Default for LazyWeak<Parent> {
fn default() -> Self {
Self::new()
}
}