diff --git a/ISSUES.md b/ISSUES.md index bd5f736..8be8efb 100644 --- a/ISSUES.md +++ b/ISSUES.md @@ -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. \ No newline at end of file +- ✅ Something appears to have broken the peers info tab, nothing shows up. \ No newline at end of file diff --git a/apps/swarm/main.c b/apps/swarm/main.c index cedeea9..45a062b 100644 --- a/apps/swarm/main.c +++ b/apps/swarm/main.c @@ -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); }