improved super seeding with strict option

This commit is contained in:
Arvid Norberg 2008-12-09 07:56:37 +00:00
parent bf4ed74c65
commit 5fb854d724
4 changed files with 33 additions and 2 deletions

View File

@ -3147,6 +3147,7 @@ that will be sent to the tracker. The user-agent is a good way to identify your
bool announce_to_all_trackers;
bool prefer_udp_trackers;
bool strict_super_seeding;
};
``user_agent`` this is the client identification to the tracker.
@ -3445,6 +3446,10 @@ trackers for the same hostname. Setting this to fails means that the
trackers' tier is respected and there's no preference of one protocol
over another.
``strict_super_seeding`` when this is set to true, a piece has to
have been forwarded to a third peer before another one is handed out.
This is the traditional definition of super seeding.
pe_settings
===========

View File

@ -146,6 +146,7 @@ namespace libtorrent
, rate_limit_ip_overhead(true)
, announce_to_all_trackers(false)
, prefer_udp_trackers(true)
, strict_super_seeding(false)
{}
// this is the user agent that will be sent to the tracker
@ -468,6 +469,10 @@ namespace libtorrent
// with udp:// protocol, it is preferred over the same
// tracker over http://.
bool prefer_udp_trackers;
// when set to true, a piece has to have been forwarded
// to a third peer before another one is handed out
bool strict_super_seeding;
};
#ifndef TORRENT_DISABLE_DHT

View File

@ -1234,7 +1234,7 @@ namespace libtorrent
return;
}
if (t->super_seeding())
if (t->super_seeding() && !m_ses.settings().strict_super_seeding)
{
// if we're superseeding and the peer just told
// us that it completed the piece we're superseeding
@ -1284,6 +1284,23 @@ namespace libtorrent
}
}
// if we're super seeding, this might mean that somebody
// forwarded this piece. In which case we need to give
// a new piece to that peer
if (t->super_seeding()
&& m_ses.settings().strict_super_seeding
&& (index != m_superseed_piece || t->num_peers() == 1))
{
for (torrent::peer_iterator i = t->begin()
, end(t->end()); i != end; ++i)
{
peer_connection* p = *i;
if (p->superseed_piece() != index) continue;
if (!p->has_piece(index)) continue;
p->superseed_piece(t->get_piece_to_super_seed(p->get_bitfield()));
}
}
if (is_seed())
{
m_peer_info->seed = true;

View File

@ -44,7 +44,7 @@ POSSIBILITY OF SUCH DAMAGE.
using boost::filesystem::remove_all;
using boost::filesystem::exists;
void test_swarm(bool super_seeding = false)
void test_swarm(bool super_seeding = false, bool strict = false)
{
using namespace libtorrent;
@ -74,6 +74,7 @@ void test_swarm(bool super_seeding = false)
session_settings settings;
settings.allow_multiple_connections_per_ip = true;
settings.ignore_limits_on_local_network = false;
settings.strict_super_seeding = strict;
ses1.set_settings(settings);
ses2.set_settings(settings);
ses3.set_settings(settings);
@ -205,6 +206,9 @@ int test_main()
// with super seeding
test_swarm(true);
// with strict super seeding
test_swarm(true, true);
return 0;
}