Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: log an error when inbound fails #13

Open
wants to merge 1 commit into
base: mainnet-staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions node/src/client/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ impl<N: Network, C: ConsensusStorage<N>> Reading for Client<N, C> {
async fn process_message(&self, peer_addr: SocketAddr, message: Self::Message) -> io::Result<()> {
// Process the message. Disconnect if the peer violated the protocol.
if let Err(error) = self.inbound(peer_addr, message).await {
error!("Failed to process inbound message from '{peer_addr}' - {error}");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This log would be almost the same as the one displayed if the peer is still connected; I'm in favor of reporting the error regardless, but I think we may want to either remove the preexisting WARN or to change its message to no longer state the error (instead it could state sth like Disconnecting from '{peer_ip}' for protocol violation).

if let Some(peer_ip) = self.router().resolve_to_listener(&peer_addr) {
warn!("Disconnecting from '{peer_ip}' - {error}");
Outbound::send(self, peer_ip, Message::Disconnect(DisconnectReason::ProtocolViolation.into()));
Expand Down
1 change: 1 addition & 0 deletions node/src/validator/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ impl<N: Network, C: ConsensusStorage<N>> Reading for Validator<N, C> {
async fn process_message(&self, peer_addr: SocketAddr, message: Self::Message) -> io::Result<()> {
// Process the message. Disconnect if the peer violated the protocol.
if let Err(error) = self.inbound(peer_addr, message).await {
error!("Failed to process inbound message from '{peer_addr}' - {error}");
if let Some(peer_ip) = self.router().resolve_to_listener(&peer_addr) {
warn!("Disconnecting from '{peer_ip}' - {error}");
Outbound::send(self, peer_ip, Message::Disconnect(DisconnectReason::ProtocolViolation.into()));
Expand Down