Skip to content

Commit d9c8ef6

Browse files
committed
f better docs/comments in MessageBuf
1 parent 57de046 commit d9c8ef6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lightning/src/ln/peer_channel_encryptor.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -536,8 +536,8 @@ impl PeerChannelEncryptor {
536536
}
537537
}
538538

539-
/// A buffer which stores an encoded message with some padding to allow for future
540-
/// encryption/MACing
539+
/// A buffer which stores an encoded message (including the two message-type bytes) with some
540+
/// padding to allow for future encryption/MACing.
541541
pub struct MessageBuf(Vec<u8>);
542542
impl MessageBuf {
543543
/// Creates a new buffer from an encoded message (i.e. the two message-type bytes followed by
@@ -548,6 +548,8 @@ impl MessageBuf {
548548
if encoded_msg.len() > LN_MAX_MSG_LEN {
549549
panic!("Attempted to encrypt message longer than 65535 bytes!");
550550
}
551+
// In addition to the message (continaing the two message type bytes), we also have to add
552+
// the message length header (and its MAC) and the message MAC.
551553
let mut res = Vec::with_capacity(encoded_msg.len() + 16*2 + 2);
552554
res.resize(encoded_msg.len() + 16 + 2, 0);
553555
res[16 + 2..].copy_from_slice(&encoded_msg);

0 commit comments

Comments
 (0)