From: Matt Corallo Date: Wed, 1 Feb 2023 21:09:46 +0000 (+0000) Subject: Suggest a socket read buffer of 4KiB to limit message count X-Git-Tag: v0.0.114-beta~22^2~3 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=34b0f2556d6dad057f9867518bd57d6e83787161;p=rust-lightning Suggest a socket read buffer of 4KiB to limit message count ...and switch the same in `lightning-net-tokio` --- diff --git a/lightning-net-tokio/src/lib.rs b/lightning-net-tokio/src/lib.rs index 9616e0db6..b259f77ef 100644 --- a/lightning-net-tokio/src/lib.rs +++ b/lightning-net-tokio/src/lib.rs @@ -176,8 +176,9 @@ impl Connection { let (event_waker, event_receiver) = mpsc::channel(1); tokio::spawn(Self::poll_event_process(peer_manager.clone(), event_receiver)); - // 8KB is nice and big but also should never cause any issues with stack overflowing. - let mut buf = [0; 8192]; + // 4KiB is nice and big without handling too many messages all at once, giving other peers + // a chance to do some work. + let mut buf = [0; 4096]; let mut our_descriptor = SocketDescriptor::new(us.clone()); // An enum describing why we did/are disconnecting: diff --git a/lightning/src/ln/peer_handler.rs b/lightning/src/ln/peer_handler.rs index cecf4332e..f24061726 100644 --- a/lightning/src/ln/peer_handler.rs +++ b/lightning/src/ln/peer_handler.rs @@ -1005,6 +1005,9 @@ impl Result {