Skip to content

Commit

Permalink
remove explicit peer for invalid url
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgeantonio21 committed Feb 6, 2025
1 parent 10c9c65 commit 2e07d33
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion atoma-p2p/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,14 @@ impl AtomaP2pNode {
);
// NOTE: We should reject the message if it fails to validate
// as it means the node is not being following the current protocol
if let AtomaP2pNodeError::UrlParseError(_) = e {
// We remove the peer from the gossipsub topic, because it is not a valid URL and therefore cannot be reached
// by clients for processing OpenAI api compatible AI requests, so these peers are not useful for the network
self.swarm
.behaviour_mut()
.gossipsub
.remove_explicit_peer(propagation_source);
}
gossipsub::MessageAcceptance::Reject
}
};
Expand Down Expand Up @@ -857,6 +865,8 @@ pub enum AtomaP2pNodeError {
UsageMetricsSerializeError(#[from] ciborium::ser::Error<std::io::Error>),
#[error("Failed to deserialize usage metrics: `{0}`")]
UsageMetricsDeserializeError(#[from] ciborium::de::Error<std::io::Error>),
#[error("Failed to parse URL: `{0}`")]
UrlParseError(#[from] url::ParseError),
}

mod utils {
Expand Down Expand Up @@ -941,7 +951,7 @@ mod utils {
"Invalid URL format, received address: {}",
usage_metrics.node_public_url
);
AtomaP2pNodeError::InvalidPublicAddressError(e.to_string())
AtomaP2pNodeError::UrlParseError(e)
})?;

// Check if the timestamp is within a reasonable time frame
Expand Down

0 comments on commit 2e07d33

Please sign in to comment.