mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-04-25 11:02:12 +00:00
* Grow noise buffers dynamically. Currently we allocate a buffer of 176 KiB for each noise state, i.e. each connection. For connections which see only small data frames this is wasteful. At the same time we limit the max. write buffer size to 16 KiB to keep the total buffer size relatively small, which results in smaller encrypted messages and also makes it less likely to ever encounter the max. noise package size of 64 KiB in practice when communicating with other nodes using the same implementation. This PR repaces the static buffer allocation with a dynamic one. We only reserve a small space for the authentication tag plus some extra reserve and are able to buffer larger data frames before encrypting. * Grow write buffer from offset. As suggested by @mxinden, this prevents increasing the write buffer up to MAX_WRITE_BUF_LEN. Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>