Skip to content

Commit

Permalink
fix: limit the number of peers to share
Browse files Browse the repository at this point in the history
Signed-off-by: ljedrz <[email protected]>
  • Loading branch information
ljedrz committed Oct 16, 2023
1 parent 19026f2 commit 5347e4b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion node/router/messages/src/peer_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ impl MessageTrait for PeerResponse {
/// Serializes the message into the buffer.
#[inline]
fn serialize<W: Write>(&self, writer: &mut W) -> Result<()> {
// Restrict the maximum number of peers to share.
(self.peers.len().min(u8::MAX as usize) as u8).write_le(&mut *writer)?;
for peer in &self.peers {
for peer in self.peers.iter().take(u8::MAX as usize) {
peer.write_le(&mut *writer)?;
}

Expand Down

0 comments on commit 5347e4b

Please sign in to comment.