Skip to content

Commit 684ae7f

Browse files
committed
Appease clippy; minor cleanup
1 parent b0cbe10 commit 684ae7f

File tree

5 files changed

+12
-11
lines changed

5 files changed

+12
-11
lines changed

deny.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
github = [
33
"mintlayer", # allow any code from mintlayer's github
44
"paritytech", # we have to use an unreleased version of parity-scale-codec at this moment
5-
"tokio-rs", # we have to use an unreleased version of tokio at this moment
65
]
76

87
[licenses]

p2p/src/net/default_backend/peer/handshake_handler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ impl HandshakeHandler {
345345
let send_result = peer_event_sender
346346
.send(PeerEvent::MisbehavedOnHandshake { error: err.clone() })
347347
.await;
348-
if let Err(_) = send_result {
348+
if send_result.is_err() {
349349
log::error!("Cannot send PeerEvent::MisbehavedOnHandshake");
350350
}
351351
}

p2p/src/net/default_backend/peer/mod.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -255,12 +255,13 @@ where
255255
biased;
256256

257257
event = backend_event_receiver.recv() => match event.ok_or(P2pError::ChannelClosed)? {
258-
BackendEvent::Accepted{ block_sync_msg_sender, transaction_sync_msg_sender } => {
258+
BackendEvent::Accepted { block_sync_msg_sender, transaction_sync_msg_sender } => {
259259
sync_msg_senders_opt = Some((block_sync_msg_sender, transaction_sync_msg_sender));
260260
},
261261
BackendEvent::SendMessage(message) => {
262262
let message_tag: MessageTag = (&*message).into();
263-
if let Err(_) = writer_cmd_sender.send(WriterCommand::SendMessage(message)) {
263+
let send_result = writer_cmd_sender.send(WriterCommand::SendMessage(message));
264+
if send_result.is_err() {
264265
log::debug!(
265266
"Socket writer task already closed when trying to send a message with tag {:?}",
266267
message_tag
@@ -316,7 +317,7 @@ where
316317
let send_result = peer_event_sender
317318
.send(PeerEvent::Misbehaved { error: err.clone() })
318319
.await;
319-
if let Err(_) = send_result {
320+
if send_result.is_err() {
320321
log::warn!("Cannot send PeerEvent::Misbehaved");
321322
}
322323
}
@@ -382,7 +383,7 @@ where
382383
let run_result = self.run_impl().await;
383384
let send_result = peer_event_sender.send(PeerEvent::ConnectionClosed).await;
384385

385-
if let Err(_) = send_result {
386+
if send_result.is_err() {
386387
// Note: this situation is likely to happen if the connection is already closed,
387388
// so it's not really an error.
388389
log::debug!("Unable to send PeerEvent::ConnectionClosed to Backend");
@@ -441,7 +442,8 @@ fn spawn_writer<S: PeerStream + 'static>(
441442
)
442443
.await;
443444

444-
if let Err(_) = event_sender.send(WriterEvent::WriterClosed(writer_result)) {
445+
let send_result = event_sender.send(WriterEvent::WriterClosed(writer_result));
446+
if send_result.is_err() {
445447
log::debug!("Peer task already closed");
446448
}
447449
},
@@ -462,7 +464,7 @@ async fn writer_loop<S: PeerStream>(
462464
WriterCommand::SendMessage(message) => {
463465
log::debug!(
464466
"Sending message {} with encoded size {}",
465-
MessageDebugLogSummary(&*message),
467+
MessageDebugLogSummary(&message),
466468
message.encoded_size()
467469
);
468470

p2p/src/net/default_backend/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ impl<'a> std::fmt::Display for MessageDebugLogSummary<'a> {
380380
TransactionResponse::Found(tx) => {
381381
write!(
382382
f,
383-
"TransactionResponse-Found(id={})",
383+
"TransactionResponse-Found(id={:x})",
384384
tx.transaction().get_id()
385385
)
386386
}

p2p/src/tests/helpers/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ impl PeerManagerObserverImpl {
9393
fn send_notification(&self, notification: PeerManagerNotification) {
9494
let send_result = self.notification_sender.send(notification.clone());
9595

96-
if let Err(_) = send_result {
96+
if send_result.is_err() {
9797
log::warn!("Error sending peer manager notification {notification:?}");
9898
}
9999
}
@@ -165,7 +165,7 @@ impl BackendObserverImpl {
165165
fn send_notification(&self, notification: BackendNotification) {
166166
let send_result = self.notification_sender.send(notification.clone());
167167

168-
if let Err(_) = send_result {
168+
if send_result.is_err() {
169169
log::warn!("Error sending backend notification {notification:?}");
170170
}
171171
}

0 commit comments

Comments
 (0)