/* Внутренний вход проверенного DATA-dispatcher: авторизация пира/handle/пути делается сетевым протоколом. * Подпись источника проверяется кольцом. Отсутствие локальной подписки отсекается до crypto/FEC. * Внешний frontend использует stream.h, а не прямую вставку сетевых блоков. */ #ifndef STREAM_PRIV_H #define STREAM_PRIV_H #include "stream.h" #include "stream_network.h" struct stream_local { struct stream_descriptor descriptor; struct stream_buffer *buffer; uint64_t start, last, next; int anchored, decoded, publisher, finished, relay_only; const uint8_t *end; }; /* Заимствованные буфер/END действуют только до следующего callback/мутации сервиса. */ struct stream_network *stream_network_get(struct UTUN_INSTANCE *inst); void stream_optimizers_tick(struct UTUN_INSTANCE *inst, uint64_t now_ms); int stream_local_get(struct UTUN_INSTANCE *inst, const struct stream_descriptor *key, struct stream_local *local); int stream_handle_context(struct STREAM_HANDLE *handle, struct UTUN_INSTANCE **inst, struct stream_descriptor *descriptor); int stream_ingest_path(struct UTUN_INSTANCE *inst, const uint8_t *wire, size_t length, const struct stream_path *path); int stream_ingest_end(struct UTUN_INSTANCE *inst, const struct stream_descriptor *key, const uint8_t *wire, size_t length); void stream_local_progress(struct UTUN_INSTANCE *inst, const struct stream_descriptor *key, uint64_t before); int stream_local_restart(struct UTUN_INSTANCE *inst, const struct stream_descriptor *key); int stream_local_metrics(struct UTUN_INSTANCE *inst, const struct stream_descriptor *key, uint8_t sub, uint64_t now_ms, struct stream_metric_snapshot *snapshot); /* Внутреннее владение точной эпохой; close обязателен и после detach. Режим существующего экземпляра сохраняется. */ int stream_relay_open(struct UTUN_INSTANCE *inst, const struct stream_descriptor *key, struct STREAM_HANDLE **out); /* Подтверждение поставщика действует только в живой попытке помощи, до прихода Merkle-опции. */ int stream_relay_confirmed(struct UTUN_INSTANCE *inst, const struct stream_descriptor *key, uint64_t peer); /* Вызывается selector один раз на экземпляр; relay-only экземпляры новых запросов помощи не создают. */ void stream_relay_demand(struct UTUN_INSTANCE *inst, const struct stream_descriptor *key, int needed, uint64_t now_ms); void stream_relay_ready(struct UTUN_INSTANCE *inst, const struct stream_descriptor *key, uint64_t peer); int stream_ingest_block(struct UTUN_INSTANCE *inst, const uint8_t *wire, size_t length); #endif