Skip to content

Commit

Permalink
refactor: Inbound::listen_for_messages is infallible
Browse files Browse the repository at this point in the history
Signed-off-by: ljedrz <[email protected]>
  • Loading branch information
ljedrz committed Jan 14, 2021
1 parent d01ee86 commit f91abb5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions network/src/inbound/inbound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl Inbound {

let inbound = inbound.clone();
tokio::spawn(async move {
inbound.listen_for_messages(remote_address, &mut reader).await.unwrap();
inbound.listen_for_messages(remote_address, &mut reader).await;
});
}
Err(e) => error!("Failed to accept a connection: {}", e),
Expand All @@ -114,7 +114,7 @@ impl Inbound {
Ok(())
}

pub async fn listen_for_messages(&self, addr: SocketAddr, reader: &mut OwnedReadHalf) -> Result<(), NetworkError> {
pub async fn listen_for_messages(&self, addr: SocketAddr, reader: &mut OwnedReadHalf) {
let mut failure_count = 0u8;
let mut disconnect_from_peer = false;
let mut failure;
Expand All @@ -139,7 +139,7 @@ impl Inbound {
// TODO (howardwu): Remove this and rearchitect how disconnects are handled using the peer manager.
// TODO (howardwu): Implement a handler so the node does not lose state of undetected disconnects.
warn!("Disconnecting from an unreliable peer");
break Ok(()); // the error has already been handled and reported
break; // the error has already been handled and reported
}
false => {
// Sleep for 10 seconds
Expand Down
2 changes: 1 addition & 1 deletion network/src/peers/peers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ impl Peers {
// spawn the inbound loop
let inbound = self.inbound.clone();
tokio::spawn(async move {
inbound.listen_for_messages(remote_address, &mut reader).await.unwrap();
inbound.listen_for_messages(remote_address, &mut reader).await;
});

// save the outbound channel
Expand Down

0 comments on commit f91abb5

Please sign in to comment.