diff --git a/libtransmission/torrent.cc b/libtransmission/torrent.cc index b0e00844b..cc04211e7 100644 --- a/libtransmission/torrent.cc +++ b/libtransmission/torrent.cc @@ -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) { diff --git a/libtransmission/torrent.h b/libtransmission/torrent.h index 7aa0f845c..31390fdc7 100644 --- a/libtransmission/torrent.h +++ b/libtransmission/torrent.h @@ -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, diff --git a/libtransmission/webseed.cc b/libtransmission/webseed.cc index 88817f5e2..5fe2d92dc 100644 --- a/libtransmission/webseed.cc +++ b/libtransmission/webseed.cc @@ -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;