kget
dht::Database Class Reference
#include <database.h>
Detailed Description
Class where all the key value paires get stored.
Definition at line 76 of file database.h.
Public Member Functions | |
| bool | checkToken (const dht::Key &token, const KNetwork::KInetSocketAddress &addr) |
| bool | contains (const dht::Key &key) const |
| Database () | |
| void | expire (bt::TimeStamp now) |
| dht::Key | genToken (const KNetwork::KInetSocketAddress &addr) |
| void | insert (const dht::Key &key) |
| void | sample (const dht::Key &key, DBItemList &dbl, bt::Uint32 max_entries) |
| void | store (const dht::Key &key, const DBItem &dbi) |
| virtual | ~Database () |
Constructor & Destructor Documentation
| dht::Database::Database | ( | ) |
Definition at line 79 of file database.cpp.
| dht::Database::~Database | ( | ) | [virtual] |
Definition at line 85 of file database.cpp.
Member Function Documentation
| bool dht::Database::checkToken | ( | const dht::Key & | token, | |
| const KNetwork::KInetSocketAddress & | addr | |||
| ) |
Check if a received token is OK.
- Parameters:
-
token The token received addr The address of the peer
- Returns:
- true if the token was given to this peer, false other wise
Definition at line 177 of file database.cpp.
| bool dht::Database::contains | ( | const dht::Key & | key | ) | const |
| void dht::Database::expire | ( | bt::TimeStamp | now | ) |
Expire all items older then 30 minutes.
- Parameters:
-
now The time it is now (we pass this along so we only have to calculate it once)
Definition at line 127 of file database.cpp.
| dht::Key dht::Database::genToken | ( | const KNetwork::KInetSocketAddress & | addr | ) |
Generate a write token, which will give peers write access to the DB.
- Parameters:
-
addr The address of the peer
- Returns:
- A Key
Definition at line 143 of file database.cpp.
| void dht::Database::insert | ( | const dht::Key & | key | ) |
Insert an empty item (only if it isn't already in the DB).
Definition at line 232 of file database.cpp.
| void dht::Database::sample | ( | const dht::Key & | key, | |
| DBItemList & | dbl, | |||
| bt::Uint32 | max_entries | |||
| ) |
Get max_entries items from the database, which have the same key, items are taken randomly from the list.
If the key is not present no items will be returned, if there are fewer then max_entries items for the key, all entries will be returned
- Parameters:
-
key The key to search for dbl The list to store the items in max_entries The maximum number entries
Definition at line 99 of file database.cpp.
Store an entry in the database.
- Parameters:
-
key The key dbi The DBItem to store
Definition at line 88 of file database.cpp.
The documentation for this class was generated from the following files:
KDE 4.2 API Reference