Skip to content

Commit

Permalink
validator-network: Don't convert network errors
Browse files Browse the repository at this point in the history
Don't convert network errors in the `send_to` function within the
`validator-network` subcrate.
  • Loading branch information
jsdanielh committed Jan 26, 2024
1 parent 9306628 commit bf0d070
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions validator-network/src/network_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,18 +205,22 @@ where
validator_id: self.local_validator_id()?,
inner: msg,
};
if let Ok(peer_id) = self.get_validator_peer_id(validator_id).await {
self.network
.message(msg, peer_id)
.map_err(|e| {
// The validator peer id might have changed and thus caused a connection failure.
self.clear_validator_peer_id_cache(validator_id);

NetworkError::Request(e)
})
.await
} else {
Err(NetworkError::Unreachable)
match self.get_validator_peer_id(validator_id).await {
Ok(peer_id) => {
self.network
.message(msg, peer_id)
.map_err(|e| {
// The validator peer id might have changed and thus caused a connection failure.
self.clear_validator_peer_id_cache(validator_id);

NetworkError::Request(e)
})
.await
}
Err(e) => {
log::error!(error = ?e, "Error getting validator peer ID");
Err(e)
}
}
}

Expand Down

0 comments on commit bf0d070

Please sign in to comment.