libktorrent  2.1.1
Classes | Public Slots | Signals | Public Member Functions | Static Public Member Functions | List of all members
bt::PeerManager Class Reference

Manages all the Peers. More...

#include <peermanager.h>

Inheritance diagram for bt::PeerManager:
Inheritance graph
[legend]

Classes

class  PeerVisitor
 

Public Slots

void peerSourceReady (PeerSource *ps)
 

Signals

void newPeer (Peer *p)
 
void peerKilled (Peer *p)
 

Public Member Functions

 PeerManager (Torrent &tor)
 
void addPotentialPeer (const net::Address &addr, bool local)
 
void bitSetReceived (Peer *p, const BitSet &bs)
 Bitset received by a peer.
 
bool chokerNeedsToRun () const
 Does the choker need to run again.
 
void closeAllConnections ()
 
bool connectedTo (const PeerID &peer_id)
 Are we connected to a Peer given it's PeerID ?
 
Peer::Ptr findPeer (PieceDownloader *pd)
 
Peer::Ptr findPeer (Uint32 peer_id)
 
const BitSetgetAvailableChunksBitSet () const
 Get a BitSet of all available chunks.
 
ChunkCountergetChunkCounter ()
 Get the chunk counter.
 
Uint32 getNumConnectedLeechers () const
 Get the number of connected leechers.
 
Uint32 getNumConnectedPeers () const
 Get the number of connected peers.
 
Uint32 getNumConnectedSeeders () const
 Get the number of connected seeders.
 
Uint32 getNumPending () const
 Get the number of pending peers we are attempting to connect to.
 
QList< Peer::Ptr > getPeers () const
 
const TorrentgetTorrent () const
 Get the Torrent.
 
void have (Peer *p, Uint32 index)
 Have message received by a peer.
 
bool isPartialSeed () const
 Are we a partial seed.
 
bool isPexEnabled () const
 Is PEX eanbled.
 
bool isStarted () const
 Is the peer manager started.
 
void killSeeders ()
 
void killStalePeers ()
 
void killUninterested ()
 
void loadPeerList (const QString &file)
 
void newConnection (mse::EncryptedPacketSocket::Ptr sock, const PeerID &peer_id, Uint32 support)
 
void pause ()
 
void peerAuthenticated (Authenticate *auth, PeerConnector::WPtr pcon, bool ok, ConnectionLimit::Token::Ptr token)
 
void pex (const QByteArray &arr)
 A PEX message was received.
 
void pieceReceived (const Piece &p)
 A Piece was received.
 
void portPacketReceived (const QString &ip, Uint16 port)
 A port packet was received.
 
void rerunChoker ()
 Rerun the choker.
 
void savePeerList (const QString &file)
 
void sendHave (Uint32 index)
 Send a have message to all peers.
 
void setGroupIDs (Uint32 up, Uint32 down)
 Set the group IDs of each peer.
 
void setPartialSeed (bool partial_seed)
 Set if we are a partial seed or not.
 
void setPexEnabled (bool on)
 Enable or disable PEX.
 
void setPieceHandler (PieceHandler *ph)
 Set the piece handler.
 
void setSuperSeeding (bool on, const BitSet &chunks)
 Enable or disable super seeding.
 
void setWantedChunks (const BitSet &bs)
 
void start (bool superseed)
 
void stop ()
 
void unpause ()
 
void update ()
 
Uint32 uploadRate () const
 Get the combined upload rate of all peers in bytes per sec.
 
void visit (PeerVisitor &visitor)
 Visit all peers.
 

Static Public Member Functions

static ConnectionLimitconnectionLimits ()
 Get the connection limits.
 

Detailed Description

Author
Joris Guisson This class manages all Peer objects. It can also open connections to other peers.

Definition at line 66 of file peermanager.h.

Constructor & Destructor Documentation

◆ PeerManager()

bt::PeerManager::PeerManager ( Torrent tor)

Constructor.

Parameters
torThe Torrent

Member Function Documentation

◆ addPotentialPeer()

void bt::PeerManager::addPotentialPeer ( const net::Address addr,
bool  local 
)

Add a potential peer

Parameters
addrThe peers' address
localIs it a peer on the local network
Returns
void

◆ closeAllConnections()

void bt::PeerManager::closeAllConnections ( )

Close all Peer connections.

◆ findPeer() [1/2]

Peer::Ptr bt::PeerManager::findPeer ( PieceDownloader pd)

Find a Peer based on it's PieceDownloader

Parameters
pdThe PieceDownloader
Returns
The matching Peer or 0 if none can be found

◆ findPeer() [2/2]

Peer::Ptr bt::PeerManager::findPeer ( Uint32  peer_id)

Find a Peer based on it's ID

Parameters
peer_idThe ID
Returns
A Peer or 0, if nothing could be found

◆ getPeers()

QList<Peer::Ptr> bt::PeerManager::getPeers ( ) const

Get a list of all peers.

Returns
A QList of Peer's

◆ killSeeders()

void bt::PeerManager::killSeeders ( )

Kills all connections to seeders. This is used when torrent download gets finished and we should drop all connections to seeders

◆ killStalePeers()

void bt::PeerManager::killStalePeers ( )

Kill all peers who appear to be stale

◆ killUninterested()

void bt::PeerManager::killUninterested ( )

Kills all peers that are not interested for a long time. This should be used when torrent is seeding ONLY.

◆ loadPeerList()

void bt::PeerManager::loadPeerList ( const QString &  file)

Load the peer list again and add them to the potential peers

◆ newConnection()

void bt::PeerManager::newConnection ( mse::EncryptedPacketSocket::Ptr  sock,
const PeerID peer_id,
Uint32  support 
)

A new connection is ready for this PeerManager.

Parameters
sockThe socket
peer_idThe Peer's ID
supportWhat extensions the peer supports

◆ pause()

void bt::PeerManager::pause ( )

Pause the peer connections

◆ peerAuthenticated()

void bt::PeerManager::peerAuthenticated ( Authenticate auth,
PeerConnector::WPtr  pcon,
bool  ok,
ConnectionLimit::Token::Ptr  token 
)

A peer has authenticated.

Parameters
authThe Authenticate object
pconThe PeerConnector
okWhether or not the attempt was succesfull
tokenThe ConnectionLimit::Token

◆ peerSourceReady

void bt::PeerManager::peerSourceReady ( PeerSource ps)
slot

A PeerSource, has new potential peers.

Parameters
psThe PeerSource

◆ savePeerList()

void bt::PeerManager::savePeerList ( const QString &  file)

Save the IP's and port numbers of all peers.

◆ start()

void bt::PeerManager::start ( bool  superseed)

Start listening to incoming requests.

Parameters
superseedSet to true to get superseeding

◆ stop()

void bt::PeerManager::stop ( )

Stop listening to incoming requests.

◆ unpause()

void bt::PeerManager::unpause ( )

Unpause the peer connections

◆ update()

void bt::PeerManager::update ( )

Check for new connections, update down and upload speed of each Peer. Initiate new connections.


The documentation for this class was generated from the following file: