diff --git a/src/piece_picker.cpp b/src/piece_picker.cpp index cdad7425e..bbacb9889 100755 --- a/src/piece_picker.cpp +++ b/src/piece_picker.cpp @@ -133,22 +133,8 @@ namespace libtorrent { int index = static_cast(i - pieces.begin()); piece_pos& p = m_piece_map[index]; - if (*i) - { - if (m_sequential_download == index) ++m_sequential_download; - ++m_num_have; - p.set_have(); - if (p.filtered()) - { - ++m_num_have_filtered; - TORRENT_ASSERT(m_num_filtered > 0); - --m_num_filtered; - } - } - else - { - p.index = 0; - } + if (*i) we_have(index); + else TORRENT_ASSERT(p.index == 0); } } diff --git a/src/torrent.cpp b/src/torrent.cpp index 39b4df523..b4dd68bd2 100755 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -605,6 +605,14 @@ namespace libtorrent } } } + + int index = 0; + for (std::vector::iterator i = m_have_pieces.begin() + , end(m_have_pieces.end()); i != end; ++i, ++index) + { + if (*i) m_picker->we_have(index); + } + TORRENT_ASSERT(m_picker->num_have_filtered() == m_num_pieces); } files_checked(); @@ -656,6 +664,8 @@ namespace libtorrent { m_have_pieces[j.offset] = true; ++m_num_pieces; + TORRENT_ASSERT(m_picker); + m_picker->we_have(j.offset); } // we're not done checking yet @@ -3766,6 +3776,7 @@ namespace libtorrent st.num_incomplete = m_incomplete; st.paused = m_paused; boost::tie(st.total_done, st.total_wanted_done) = bytes_done(); + TORRENT_ASSERT(st.total_wanted_done >= 0); TORRENT_ASSERT(st.total_done >= st.total_wanted_done); // payload transfer @@ -3826,6 +3837,7 @@ namespace libtorrent // fill in status that depends on metadata st.total_wanted = m_torrent_file->total_size(); + TORRENT_ASSERT(st.total_wanted >= 0); if (m_picker.get() && (m_picker->num_filtered() > 0 || m_picker->num_have_filtered() > 0))