char const* hash_for_piece_ptr(int index) const
		{
			TORRENT_ASSERT(index >= 0);
			TORRENT_ASSERT(index < m_files.num_pieces());
			TORRENT_ASSERT(is_loaded());
			if (is_merkle_torrent())
			{
				TORRENT_ASSERT(index < int(m_merkle_tree.size() - m_merkle_first_leaf));
				return m_merkle_tree[m_merkle_first_leaf + index].data();
			}
			else
			{
				TORRENT_ASSERT(m_piece_hashes);
				TORRENT_ASSERT(m_piece_hashes >= m_info_section.get());
				TORRENT_ASSERT(m_piece_hashes < m_info_section.get() + m_info_section_size);
				TORRENT_ASSERT(index < int(m_info_section_size / 20));
				return &m_piece_hashes[index*20];
			}
		}
示例#2
0
		char const* hash_for_piece_ptr(piece_index_t const index) const
		{
			TORRENT_ASSERT(index >= piece_index_t(0));
			TORRENT_ASSERT(index < m_files.end_piece());
			TORRENT_ASSERT(is_loaded());
			int const idx = static_cast<int>(index);
			if (is_merkle_torrent())
			{
				TORRENT_ASSERT(idx < int(m_merkle_tree.size() - m_merkle_first_leaf));
				return m_merkle_tree[m_merkle_first_leaf + idx].data();
			}
			else
			{
				TORRENT_ASSERT(m_piece_hashes);
				TORRENT_ASSERT(m_piece_hashes >= m_info_section.get());
				TORRENT_ASSERT(m_piece_hashes < m_info_section.get() + m_info_section_size);
				TORRENT_ASSERT(idx < int(m_info_section_size / 20));
				return &m_piece_hashes[idx * 20];
			}
		}