mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: remove some more usages of BytesMut (#9025)
This commit is contained in:
@ -312,13 +312,14 @@ impl ProtocolProxy {
|
||||
return Err(io::ErrorKind::InvalidInput.into())
|
||||
}
|
||||
|
||||
let mut masked_bytes = BytesMut::zeroed(msg.len());
|
||||
masked_bytes[0] = msg[0]
|
||||
.checked_add(self.shared_cap.relative_message_id_offset())
|
||||
.ok_or(io::ErrorKind::InvalidInput)?;
|
||||
let offset = self.shared_cap.relative_message_id_offset();
|
||||
if offset == 0 {
|
||||
return Ok(msg);
|
||||
}
|
||||
|
||||
masked_bytes[1..].copy_from_slice(&msg[1..]);
|
||||
Ok(masked_bytes.freeze())
|
||||
let mut masked = Vec::from(msg);
|
||||
masked[0] = masked[0].checked_add(offset).ok_or(io::ErrorKind::InvalidInput)?;
|
||||
Ok(masked.into())
|
||||
}
|
||||
|
||||
/// Unmasks the message ID of a message received from the wire.
|
||||
|
||||
Reference in New Issue
Block a user