Package DebTorrent :: Package BT1 :: Module Choker :: Class Choker
[hide private]
[frames] | no frames]

Class Choker

source code

Manages the choking and unchoking of other downloaders.

Instance Methods [hide private]
 
__init__(self, config, schedule, picker, done=<function <lambda> at 0x2b5519393d70>)
Initialize the Choker instance.
source code
 
set_round_robin_period(self, x)
Set a new round-robin period.
source code
 
_round_robin(self)
Periodically determine the ordering for connections and call the choker.
source code
 
_rechoke(self)
Unchoke some connections.
source code
 
connection_made(self, connection, p=None)
Adds a new connection to the list.
source code
 
connection_lost(self, connection)
Removes a lost connection from the list.
source code
 
interested(self, connection)
Indicate the connection is now interesting.
source code
 
not_interested(self, connection)
Indicate the connection is no longer interesting.
source code
 
set_super_seed(self)
Change to super seed state.
source code
 
pause(self, flag)
Pause the choker.
source code
Instance Variables [hide private]
dictonary config
the configuration variables
list of Connecter.Connection connections
the connections from peers to the client
Event done
flag to indicate when the download is complete
int last_preferred
the number of preferred connections found in the last examination
long last_round_robin
the last time the connections were examined
Event paused
flag to indicate when the download is paused
PiecePicker picker
the PiecePicker to get connection information from
int round_robin_period
the number of seconds between the client's switching of upload targets
method schedule
the method to call to schedule future events
boolean super_seed
whether super-seeding is enabled
Method Details [hide private]

__init__(self, config, schedule, picker, done=<function <lambda> at 0x2b5519393d70>)
(Constructor)

source code 
Initialize the Choker instance.
Parameters:
  • config (dictonary) - the configuration variables
  • schedule (method) - the method to call to schedule future events
  • picker (PiecePicker) - the piece picker to use to
  • done (Event) - flag to indicate when the download is complete

set_round_robin_period(self, x)

source code 
Set a new round-robin period.
Parameters:
  • x (int) - the new round-robin period

_rechoke(self)

source code 

Unchoke some connections.

Reads the current upload and download rates from the connections, as well as the connection state, and unchokes the most preferable ones.

connection_made(self, connection, p=None)

source code 
Adds a new connection to the list.
Parameters:
  • connection (Connecter.Connection) - the connection to the client from the peer
  • p (int) - the location to insert the new connection into the list (optional, default is to choose a random location)

connection_lost(self, connection)

source code 
Removes a lost connection from the list.
Parameters:

interested(self, connection)

source code 
Indicate the connection is now interesting.
Parameters:

not_interested(self, connection)

source code 
Indicate the connection is no longer interesting.
Parameters:

pause(self, flag)

source code 
Pause the choker.
Parameters:
  • flag (Event) - flag to indicate when pausing is finished