libktorrent  2.2.0
Classes | Public Types | Public Member Functions | List of all members
dht::KBucket Class Reference

#include <kbucket.h>

Inheritance diagram for dht::KBucket:
Inheritance graph
[legend]

Classes

class  UnableToSplit
 

Public Types

typedef QSharedPointer< KBucketPtr
 

Public Member Functions

 KBucket (const dht::Key &min_key, const dht::Key &max_key, RPCServerInterface *srv, const Key &our_id)
 
 KBucket (RPCServerInterface *srv, const Key &our_id)
 
bool contains (const KBucketEntry &entry) const
 See if this bucket contains an entry.
 
void findKClosestNodes (KClosestNodesSearch &kns)
 
bt::Uint32 getNumEntries () const
 Get the number of entries.
 
bool insert (const KBucketEntry &entry)
 
bool keyInRange (const dht::Key &k) const
 Does the key k lies in in the range of this bucket.
 
const KBucketEntryleastRecentlySeen () const
 Get the least recently seen node.
 
void load (bt::BDictNode *dict)
 Load the bucket from a file.
 
const dht::KeymaxKey () const
 Get the max key.
 
const dht::KeyminKey () const
 Get the min key.
 
bool needsToBeRefreshed () const
 Check if the bucket needs to be refreshed.
 
bool onTimeout (const net::Address &addr)
 
void save (bt::BEncoder &enc)
 save the bucket to a file
 
void setRefreshTask (Task *t)
 Set the refresh task.
 
std::pair< KBucket::Ptr, KBucket::Ptr > split () throw (UnableToSplit)
 
bool splitAllowed () const
 Are we allowed to split.
 
void updateRefreshTimer ()
 Update the refresh timer of the bucket.
 
- Public Member Functions inherited from dht::RPCCallListener
 RPCCallListener (QObject *parent)
 

Additional Inherited Members

- Public Slots inherited from dht::RPCCallListener

Detailed Description

Author
Joris Guisson

A KBucket is just a list of KBucketEntry objects. The list is sorted by time last seen : The first element is the least recently seen, the last the most recently seen.

Definition at line 55 of file kbucket.h.

Member Function Documentation

◆ findKClosestNodes()

void dht::KBucket::findKClosestNodes ( KClosestNodesSearch kns)

Find the K closest entries to a key and store them in the KClosestNodesSearch object.

Parameters
knsThe object to storre the search results

◆ insert()

bool dht::KBucket::insert ( const KBucketEntry entry)

Inserts an entry into the bucket.

Parameters
entryThe entry to insert
Returns
true If the bucket needs to be split, false otherwise

◆ onTimeout()

bool dht::KBucket::onTimeout ( const net::Address addr)

A peer failed to respond

Parameters
addrAddress of the peer

◆ split()

std::pair<KBucket::Ptr, KBucket::Ptr> dht::KBucket::split ( )
throw (UnableToSplit
)

Split the bucket in two new buckets, each containing half the range of the original one.

Returns
A pair of KBucket's
Exceptions
UnableToSplitif something goes wrong

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