swarm: populate per-peer stats for the web UI peers tab
report_progress now fills peer_stats via engine_peer_list, so the peer list (ip, progress, dl rate, state) shows again. Mark #12 done. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
1e469a0483
commit
187e8f2db2
2 changed files with 23 additions and 1 deletions
|
|
@ -9,4 +9,4 @@
|
|||
- ✅ Pausing a torrent will go back into Downloading and Seeding.
|
||||
- ⬛ A torrents data could overlap with another existing torrent. This should be blocked to avoid
|
||||
- ⬛ A paused torrent should still do a full piece check.
|
||||
- ⬛ Something appears to have broken the peers info tab, nothing shows up.
|
||||
- ✅ Something appears to have broken the peers info tab, nothing shows up.
|
||||
|
|
@ -250,6 +250,28 @@ static void report_progress(const naut_swarm_config *config,
|
|||
if (download)
|
||||
stats.piece_state_count = (uint32_t)naut_download_piece_states(
|
||||
download, stats.piece_states, NAUT_SWARM_MAX_PIECE_STATS);
|
||||
if (eng) {
|
||||
engine_peer_info peers[NAUT_SWARM_MAX_PEER_STATS];
|
||||
uint32_t pc = engine_peer_list(eng, torrent_id, peers,
|
||||
NAUT_SWARM_MAX_PEER_STATS);
|
||||
stats.peer_count = pc;
|
||||
for (uint32_t i = 0; i < pc; i++) {
|
||||
naut_swarm_peer_stats *o = &stats.peer_stats[i];
|
||||
memset(o, 0, sizeof *o);
|
||||
snprintf(o->ip, sizeof o->ip, "%.45s", peers[i].ip);
|
||||
o->port = peers[i].port;
|
||||
snprintf(o->connection, sizeof o->connection, "BT");
|
||||
snprintf(o->flags, sizeof o->flags, "%s",
|
||||
peers[i].state == PEER_STATE_RUNNING
|
||||
? (peers[i].unchoked ? "D" : "d") : "K");
|
||||
o->progress = peers[i].num_pieces
|
||||
? (double)peers[i].have_pieces / (double)peers[i].num_pieces
|
||||
: 0.0;
|
||||
o->relevance = o->progress;
|
||||
o->dlspeed = peers[i].rate_bps;
|
||||
o->downloaded = peers[i].bytes_received;
|
||||
}
|
||||
}
|
||||
config->on_progress(config->context, &stats);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue