Expose peer and piece state to web UI

This commit is contained in:
ookami125 2026-06-17 01:29:44 -04:00
parent f4f4e86be4
commit 6ae72907b0
6 changed files with 213 additions and 11 deletions

View file

@ -87,5 +87,7 @@ bool naut_download_complete(const naut_download *d);
uint32_t naut_download_num_pieces(const naut_download *d);
uint32_t naut_download_pieces_done(const naut_download *d);
uint64_t naut_download_bytes_done(const naut_download *d);
size_t naut_download_piece_states(const naut_download *d, uint8_t *out,
size_t capacity);
#endif /* NAUT_PIECE_H */

View file

@ -11,6 +11,23 @@
#include "naut/event.h"
#include "naut/storage.h"
#define NAUT_SWARM_MAX_PEER_STATS 64
#define NAUT_SWARM_MAX_PIECE_STATS 4000
typedef struct {
char ip[46];
uint16_t port;
char client[64];
char connection[16];
char flags[16];
double progress;
double relevance;
double dlspeed;
double upspeed;
uint64_t downloaded;
uint64_t uploaded;
} naut_swarm_peer_stats;
typedef struct {
uint64_t total_bytes;
uint64_t bytes_done;
@ -21,6 +38,10 @@ typedef struct {
uint32_t peers_active;
uint32_t peers_failed;
double elapsed_seconds;
uint32_t peer_count;
naut_swarm_peer_stats peer_stats[NAUT_SWARM_MAX_PEER_STATS];
uint32_t piece_state_count;
uint8_t piece_states[NAUT_SWARM_MAX_PIECE_STATS];
} naut_swarm_stats;
typedef void (*naut_swarm_progress_cb)(void *context,