Permalink
Browse files

Prevent trackers from being hammered

  • Loading branch information...
1 parent 0ffae47 commit 5e9298196d43ea595367c20128e9eb2c65aaecfe @sanko committed Sep 26, 2012
Showing with 7 additions and 25 deletions.
  1. +7 −25 lib/AnyEvent/BitTorrent.pm
@@ -500,30 +500,11 @@ sub hashcheck (;@) {
: $s->_trigger_hash_fail($index);
}
}
-has peers => (
- is => 'ro',
- isa => 'HashRef',
- lazy => 1,
- clearer => '_clear_peers',
- builder => '_build_peers'
-
- # { handle => AnyEvent::Handle
- # peerid => 'Str'
- # reserved => 'Str'
- # bitfield => 'Str'
- # remote_choked => 1
- # remote_interested => 0
- # remote_requests => ArrayRef[ArrayRef] # List of [i, o, l]
- # local_choked => 1
- # local_interested => 0
- # local_requests => ArrayRef[ArrayRef] # List of [i, o, l]
- # timeout => AnyEvent::timer
- # keepalive => AnyEvent::timer
- # local_allowed => ArrayRef
- # remote_allowed => ArrayRef
- # local_suggest => ArrayRef
- # remote_suggest => ArrayRef
- # }
+has peers => (is => 'ro',
+ isa => 'HashRef',
+ lazy => 1,
+ clearer => '_clear_peers',
+ builder => '_build_peers'
);
sub _build_peers { {} }
@@ -592,6 +573,7 @@ has trackers => (
incomplete => 0,
peers => '',
peers6 => '',
+ announcer => undef,
ticker => AE::timer(
1,
15 * 60,
@@ -627,7 +609,7 @@ sub announce {
my ($s, $e) = @_;
return if $a++ > 10; # Retry attempts
for my $tier (@{$s->trackers}) {
- $s->_announce_tier($e, $tier);
+ $tier->{announcer} //= $s->_announce_tier($e, $tier);
}
}

0 comments on commit 5e92981

Please sign in to comment.