Expose peer and piece state to web UI
This commit is contained in:
parent
f4f4e86be4
commit
6ae72907b0
6 changed files with 213 additions and 11 deletions
|
|
@ -391,3 +391,17 @@ bool naut_download_in_endgame(const naut_download *d) { return d->endgame; }
|
|||
uint32_t naut_download_num_pieces(const naut_download *d) { return d->num_pieces; }
|
||||
uint32_t naut_download_pieces_done(const naut_download *d) { return d->pieces_done; }
|
||||
uint64_t naut_download_bytes_done(const naut_download *d) { return d->bytes_done; }
|
||||
size_t naut_download_piece_states(const naut_download *d, uint8_t *out,
|
||||
size_t capacity) {
|
||||
if (!d || !out || capacity == 0) return 0;
|
||||
size_t count = NAUT_MIN((size_t)d->num_pieces, capacity);
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
if (naut_bitfield_test(&d->have, i))
|
||||
out[i] = 2;
|
||||
else if (d->ps[i])
|
||||
out[i] = 1;
|
||||
else
|
||||
out[i] = 0;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue