Skip to content

Commit e0c4fab

Browse files
committed
f use link references so its clear what capacity means
1 parent 2c315a3 commit e0c4fab

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lightning/src/ln/peer_channel_encryptor.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,11 @@ impl PeerChannelEncryptor {
431431
///
432432
/// `msgbuf` must begin with 16 + 2 dummy/0 bytes, which will be filled with the encrypted
433433
/// message length and its MAC. It should then be followed by the message bytes themselves
434-
/// (including the two byte message type), and have an extra 16 bytes of capacity remaining for
435-
/// the message MAC, which will be appended to the vec.
434+
/// (including the two byte message type).
435+
///
436+
/// For effeciency, the [`Vec::capacity`] should be at least 16 bytes larger than the
437+
/// [`Vec::length`], to avoid reallocating for the message MAC, which will be appended to the
438+
/// vec.
436439
fn encrypt_message_with_header_0s(&mut self, msgbuf: &mut Vec<u8>) {
437440
let msg_len = msgbuf.len() - 16 - 2;
438441
if msg_len > LN_MAX_MSG_LEN {

0 commit comments

Comments
 (0)