25 #include <util/constants.h>
26 #include <net/address.h>
29 #include "kbucketentry.h"
38 class RPCServerInterface;
39 class KClosestNodesSearch;
42 const bt::Uint32 K = 20;
43 const bt::Uint32 BUCKET_MAGIC_NUMBER = 0xB0C4B0C4;
44 const bt::Uint32 BUCKET_REFRESH_INTERVAL = 15 * 60 * 1000;
64 typedef QSharedPointer<KBucket> Ptr;
133 void onResponse(
RPCCall* c, RPCMsg::Ptr rsp)
override;
135 void pingQuestionable(
const KBucketEntry & replacement_entry);
139 void onFinished(
Task* t);
143 QList<KBucketEntry> entries, pending_entries;
146 QMap<RPCCall*, KBucketEntry> pending_entries_busy_pinging;
147 mutable bt::TimeStamp last_modified;
153 inline uint qHash(
const T & e)
Helper class to b-encode stuff.
bt::Uint32 getNumEntries() const
Get the number of entries.
void updateRefreshTimer()
Update the refresh timer of the bucket.
void findKClosestNodes(KClosestNodesSearch &kns)
void save(bt::BEncoder &enc)
save the bucket to a file
Key in the distributed hash table.
void load(bt::BDictNode *dict)
Load the bucket from a file.
bool onTimeout(const net::Address &addr)
bool splitAllowed() const
Are we allowed to split.
std::pair< KBucket::Ptr, KBucket::Ptr > split()
bool keyInRange(const dht::Key &k) const
Does the key k lies in in the range of this bucket.
const dht::Key & maxKey() const
Get the max key.
const dht::Key & minKey() const
Get the min key.
bool contains(const KBucketEntry &entry) const
See if this bucket contains an entry.
void setRefreshTask(Task *t)
Set the refresh task.
bool insert(const KBucketEntry &entry)
Represents a dictionary in bencoded data.
const KBucketEntry & leastRecentlySeen() const
Get the least recently seen node.
bool needsToBeRefreshed() const
Check if the bucket needs to be refreshed.