chore: remove tr_pieceOffset() (#2346)

This commit is contained in:
Charles Kerr 2021-12-26 11:25:51 -06:00 committed by GitHub
parent a515c1d94b
commit af183b1423
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 2 additions and 17 deletions

View File

@ -2020,7 +2020,7 @@ bool tr_torrentReqIsValid(tr_torrent const* tor, tr_piece_index_t index, uint32_
{
err = 4;
}
else if (tr_pieceOffset(tor, index, offset, length) > tor->totalSize())
else if (tor->offset(index, offset, length) > tor->totalSize())
{
err = 5;
}
@ -2039,19 +2039,6 @@ bool tr_torrentReqIsValid(tr_torrent const* tor, tr_piece_index_t index, uint32_
return err == 0;
}
// TODO(ckerr) migrate to block_info
uint64_t tr_pieceOffset(tr_torrent const* tor, tr_piece_index_t index, uint32_t offset, uint32_t length)
{
TR_ASSERT(tr_isTorrent(tor));
auto ret = uint64_t{};
ret = tor->pieceSize();
ret *= index;
ret += offset;
ret += length;
return ret;
}
// TODO(ckerr) migrate to fpm
tr_block_span_t tr_torGetFileBlockSpan(tr_torrent const* tor, tr_file_index_t const i)
{

View File

@ -79,8 +79,6 @@ tr_torrent* tr_torrentFindFromObfuscatedHash(tr_session* session, tr_sha1_digest
bool tr_torrentReqIsValid(tr_torrent const* tor, tr_piece_index_t index, uint32_t offset, uint32_t length);
uint64_t tr_pieceOffset(tr_torrent const* tor, tr_piece_index_t index, uint32_t offset, uint32_t length);
void tr_torrentGetBlockLocation(
tr_torrent const* tor,
tr_block_index_t block,

View File

@ -520,7 +520,7 @@ static void task_request_next_chunk(struct tr_webseed_task* t)
auto const piece_size = tor->pieceSize();
uint64_t const remain = t->length - t->blocks_done * tor->block_size - evbuffer_get_length(t->content);
uint64_t const total_offset = tr_pieceOffset(tor, t->piece_index, t->piece_offset, t->length - remain);
auto const total_offset = tor->offset(t->piece_index, t->piece_offset, t->length - remain);
tr_piece_index_t const step_piece = total_offset / piece_size;
uint64_t const step_piece_offset = total_offset - uint64_t(piece_size) * step_piece;