forked from premiere/premiere-libtorrent
support torrents with more than 262000 pieces
This commit is contained in:
parent
b29b2314b2
commit
6fc580e0cb
|
@ -1,6 +1,7 @@
|
||||||
|
|
||||||
0.16 release
|
0.16 release
|
||||||
|
|
||||||
|
* support torrents with more than 262000 pieces
|
||||||
* make tracker back-off configurable
|
* make tracker back-off configurable
|
||||||
* don't restart the swarm after downloading metadata from magnet links
|
* don't restart the swarm after downloading metadata from magnet links
|
||||||
* lower the default tracker retry intervals
|
* lower the default tracker retry intervals
|
||||||
|
|
|
@ -399,6 +399,12 @@ inline int snprintf(char* buf, int len, char const* fmt, ...)
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// if set to true, piece picker will use less RAM
|
||||||
|
// but only support up to ~260000 pieces in a torrent
|
||||||
|
#ifndef TORRENT_COMPACT_PICKER
|
||||||
|
#define TORRENT_COMPACT_PICKER 0
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef TORRENT_USE_I2P
|
#ifndef TORRENT_USE_I2P
|
||||||
#define TORRENT_USE_I2P 1
|
#define TORRENT_USE_I2P 1
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -387,11 +387,15 @@ namespace libtorrent
|
||||||
|
|
||||||
// the number of peers that has this piece
|
// the number of peers that has this piece
|
||||||
// (availability)
|
// (availability)
|
||||||
unsigned peer_count : 9;
|
#if TORRENT_COMPACT_PICKER
|
||||||
|
boost::uint32_t peer_count : 9;
|
||||||
|
#else
|
||||||
|
boost::uint32_t peer_count : 16;
|
||||||
|
#endif
|
||||||
// is 1 if the piece is marked as being downloaded
|
// is 1 if the piece is marked as being downloaded
|
||||||
unsigned downloading : 1;
|
boost::uint32_t downloading : 1;
|
||||||
// set when downloading, but no free blocks to request left
|
// set when downloading, but no free blocks to request left
|
||||||
unsigned full : 1;
|
boost::uint32_t full : 1;
|
||||||
// is 0 if the piece is filtered (not to be downloaded)
|
// is 0 if the piece is filtered (not to be downloaded)
|
||||||
// 1 is normal priority (default)
|
// 1 is normal priority (default)
|
||||||
// 2 is higher priority than pieces at the same availability level
|
// 2 is higher priority than pieces at the same availability level
|
||||||
|
@ -399,20 +403,32 @@ namespace libtorrent
|
||||||
// 4 is higher priority than partial pieces
|
// 4 is higher priority than partial pieces
|
||||||
// 5 and 6 same priority as availability 1 (ignores availability)
|
// 5 and 6 same priority as availability 1 (ignores availability)
|
||||||
// 7 is maximum priority (ignores availability)
|
// 7 is maximum priority (ignores availability)
|
||||||
unsigned piece_priority : 3;
|
boost::uint32_t piece_priority : 3;
|
||||||
// index in to the piece_info vector
|
// index in to the piece_info vector
|
||||||
unsigned index : 18;
|
#if TORRENT_COMPACT_PICKER
|
||||||
|
boost::uint32_t index : 18;
|
||||||
|
#else
|
||||||
|
boost::uint32_t index;
|
||||||
|
#endif
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
// index is set to this to indicate that we have the
|
// index is set to this to indicate that we have the
|
||||||
// piece. There is no entry for the piece in the
|
// piece. There is no entry for the piece in the
|
||||||
// buckets if this is the case.
|
// buckets if this is the case.
|
||||||
|
#if TORRENT_COMPACT_PICKER
|
||||||
we_have_index = 0x3ffff,
|
we_have_index = 0x3ffff,
|
||||||
|
#else
|
||||||
|
we_have_index = 0xffffffff,
|
||||||
|
#endif
|
||||||
// the priority value that means the piece is filtered
|
// the priority value that means the piece is filtered
|
||||||
filter_priority = 0,
|
filter_priority = 0,
|
||||||
// the max number the peer count can hold
|
// the max number the peer count can hold
|
||||||
|
#if TORRENT_COMPACT_PICKER
|
||||||
max_peer_count = 0x1ff
|
max_peer_count = 0x1ff
|
||||||
|
#else
|
||||||
|
max_peer_count = 0xffff
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
bool have() const { return index == we_have_index; }
|
bool have() const { return index == we_have_index; }
|
||||||
|
@ -469,7 +485,11 @@ namespace libtorrent
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
#if TORRENT_COMPACT_PICKER
|
||||||
BOOST_STATIC_ASSERT(sizeof(piece_pos) == sizeof(char) * 4);
|
BOOST_STATIC_ASSERT(sizeof(piece_pos) == sizeof(char) * 4);
|
||||||
|
#else
|
||||||
|
BOOST_STATIC_ASSERT(sizeof(piece_pos) == sizeof(char) * 8);
|
||||||
|
#endif
|
||||||
|
|
||||||
void update_pieces() const;
|
void update_pieces() const;
|
||||||
|
|
||||||
|
|
|
@ -269,7 +269,11 @@ namespace libtorrent
|
||||||
|
|
||||||
void piece_picker::check_invariant(const torrent* t) const
|
void piece_picker::check_invariant(const torrent* t) const
|
||||||
{
|
{
|
||||||
|
#if TORRENT_COMPACT_PICKER
|
||||||
TORRENT_ASSERT(sizeof(piece_pos) == 4);
|
TORRENT_ASSERT(sizeof(piece_pos) == 4);
|
||||||
|
#else
|
||||||
|
TORRENT_ASSERT(sizeof(piece_pos) == 8);
|
||||||
|
#endif
|
||||||
TORRENT_ASSERT(m_num_have >= 0);
|
TORRENT_ASSERT(m_num_have >= 0);
|
||||||
TORRENT_ASSERT(m_num_have_filtered >= 0);
|
TORRENT_ASSERT(m_num_have_filtered >= 0);
|
||||||
TORRENT_ASSERT(m_num_filtered >= 0);
|
TORRENT_ASSERT(m_num_filtered >= 0);
|
||||||
|
|
Loading…
Reference in New Issue