libktorrent
2.1.1
|
#include <database.h>
Public Member Functions | |
bool | checkToken (const dht::Key &token, const net::Address &addr) |
bool | contains (const dht::Key &key) const |
Test whether or not the DB contains a key. | |
void | expire (bt::TimeStamp now) |
dht::Key | genToken (const net::Address &addr) |
void | insert (const dht::Key &key) |
Insert an empty item (only if it isn't already in the DB) | |
void | sample (const dht::Key &key, DBItemList &dbl, bt::Uint32 max_entries, bt::Uint32 ip_version) |
void | store (const dht::Key &key, const DBItem &dbi) |
Class where all the key value paires get stored.
Definition at line 96 of file database.h.
bool dht::Database::checkToken | ( | const dht::Key & | token, |
const net::Address & | addr | ||
) |
Check if a received token is OK.
token | The token received |
addr | The address of the peer |
void dht::Database::expire | ( | bt::TimeStamp | now | ) |
Expire all items older then 30 minutes
now | The time it is now (we pass this along so we only have to calculate it once) |
dht::Key dht::Database::genToken | ( | const net::Address & | addr | ) |
Generate a write token, which will give peers write access to the DB.
addr | The address of the peer |
void dht::Database::sample | ( | const dht::Key & | key, |
DBItemList & | dbl, | ||
bt::Uint32 | max_entries, | ||
bt::Uint32 | ip_version | ||
) |
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
key | The key to search for |
dbl | The list to store the items in |
max_entries | The maximum number entries |
ip_version | Wanted IP version (4 or 6) |
Store an entry in the database
key | The key |
dbi | The DBItem to store |