connectd: add "use_uniform_writes" per-peer helper.
What changed, and why it matters
This commit is a small internal code cleanup in Core Lightning's connection handling. It replaces two direct checks of a developer-only padding flag with a helper function named `use_uniform_writes()`. There is no change to behavior, no fix for a bug, and no indication of a security issue.
No security action needed. Treat as normal code maintenance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch refactors connectd/multiplex.c to introduce use_uniform_writes(peer), which simply returns peer->daemon->dev_uniform_padding. Two call sites that previously checked the flag directly now call the helper. The logic and behavior are unchanged; this is a pure maintainability refactor.
Changed components
connectd/multiplex.cInspect captured patch +8 / −4
diff --git a/connectd/multiplex.c b/connectd/multiplex.c
index 8cfaa885..73392cee 100644
--- a/connectd/multiplex.c
+++ b/connectd/multiplex.c
@@ -481,14 +481,18 @@ static bool have_empty_encrypted_queue(const struct peer *peer)
return membuf_num_elems(&peer->encrypted_peer_out) == 0;
}
+static bool use_uniform_writes(const struct peer *peer)
+{
+ return peer->daemon->dev_uniform_padding;
+}
+
/* (Continue) writing the encrypted_peer_out array */
static struct io_plan *write_encrypted_to_peer(struct peer *peer)
{
size_t avail = membuf_num_elems(&peer->encrypted_peer_out);
/* With padding: always a full uniform-size chunk.
* Without: flush whatever we have (caller ensures non-zero). */
- size_t write_size = peer->daemon->dev_uniform_padding
- ? UNIFORM_MESSAGE_SIZE : avail;
+ size_t write_size = use_uniform_writes(peer) ? UNIFORM_MESSAGE_SIZE : avail;
assert(avail >= write_size && write_size > 0);
return io_write_partial(peer->to_peer,
@@ -1250,8 +1254,8 @@ static struct io_plan *write_to_peer(struct io_conn *peer_conn,
/* Wait for them to wake us */
return msg_queue_wait(peer_conn, peer->peer_outq, write_to_peer, peer);
}
- /* OK, add padding (only if --dev-uniform-padding enabled). */
- if (peer->daemon->dev_uniform_padding)
+ /* OK, add padding (only if supported). */
+ if (use_uniform_writes(peer))
pad_encrypted_queue(peer);
else
break;
Why this scored 11/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.