chore: remove tr_pieceOffset() (#2346)
This commit is contained in:
parent
a515c1d94b
commit
af183b1423
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue