From 6a5bb84d71d553e368d485ab89d1a30891fcc612 Mon Sep 17 00:00:00 2001 From: evgeny Date: Tue, 13 Oct 2026 20:09:14 +0200 Subject: [PATCH] Centralize default stream input capacity with batch overhead --- src/stream/stream.c | 2 +- src/stream/stream_proto.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/stream/stream.c b/src/stream/stream.c index 2180426e..cd90cf66 100644 --- a/src/stream/stream.c +++ b/src/stream/stream.c @@ -599,7 +599,7 @@ int stream_publish_open(struct UTUN_INSTANCE *inst, uint64_t group_id, const str int result = stream_open_check(inst, group_id, out); if (result != STREAM_OK) return result; struct stream_descriptor d = {.group_id = group_id, .source_node_id = inst->node_id, - .n = parameters ? parameters->n : 8, .r = parameters ? parameters->r : 2, + .n = parameters ? parameters->n : STREAM_DEFAULT_N, .r = parameters ? parameters->r : STREAM_DEFAULT_R, .block_size = parameters ? parameters->block_size : STREAM_RS_DEFAULT_SIZE}; do { if (random_bytes((uint8_t *)&d.source_epoch, sizeof(d.source_epoch)) != 0) { diff --git a/src/stream/stream_proto.h b/src/stream/stream_proto.h index 6751e2a9..cd8510ce 100644 --- a/src/stream/stream_proto.h +++ b/src/stream/stream_proto.h @@ -31,6 +31,10 @@ #define STREAM_BATCH_OVERHEAD (STREAM_BATCH_HEADER + SC_SIGN_SIZE) #define STREAM_BLOCK_DEFAULT_SIZE 1300 #define STREAM_RS_DEFAULT_SIZE (STREAM_BLOCK_DEFAULT_SIZE - STREAM_BLOCK_OVERHEAD) +#define STREAM_DEFAULT_N 8 +#define STREAM_DEFAULT_R 2 +#define STREAM_DEFAULT_INPUT_CAPACITY \ + ((STREAM_DEFAULT_N - STREAM_DEFAULT_R) * (STREAM_RS_DEFAULT_SIZE - RS_HEADER_SIZE) - STREAM_BATCH_OVERHEAD) #define STREAM_BLOCK_MAX_SIZE (RS_MAX_BLOCK_SIZE + STREAM_BLOCK_OVERHEAD) #define STREAM_BLOCK_TIME_RESET 0x01 #define STREAM_BUFFER_BYTES (32u * 1024u * 1024u)