Changeset View
Changeset View
Standalone View
Standalone View
src/dht/database.h
Show First 20 Lines • Show All 106 Lines • ▼ Show 20 Line(s) | 80 | public: | |||
---|---|---|---|---|---|
107 | * (we pass this along so we only have to calculate it once) | 107 | * (we pass this along so we only have to calculate it once) | ||
108 | */ | 108 | */ | ||
109 | void expire(bt::TimeStamp now); | 109 | void expire(bt::TimeStamp now); | ||
110 | 110 | | |||
111 | /** | 111 | /** | ||
112 | * Generate a write token, which will give peers write access to | 112 | * Generate a write token, which will give peers write access to | ||
113 | * the DB. | 113 | * the DB. | ||
114 | * @param addr The address of the peer | 114 | * @param addr The address of the peer | ||
115 | * @return A Key | 115 | * @return A QByteArray | ||
116 | */ | 116 | */ | ||
117 | dht::Key genToken(const net::Address & addr); | 117 | QByteArray genToken(const net::Address & addr); | ||
118 | 118 | | |||
119 | /** | 119 | /** | ||
120 | * Check if a received token is OK. | 120 | * Check if a received token is OK. | ||
121 | * @param token The token received | 121 | * @param token The token received | ||
122 | * @param addr The address of the peer | 122 | * @param addr The address of the peer | ||
123 | * @return true if the token was given to this peer, false other wise | 123 | * @return true if the token was given to this peer, false other wise | ||
124 | */ | 124 | */ | ||
125 | bool checkToken(const dht::Key & token, const net::Address & addr); | 125 | bool checkToken(const QByteArray & token, const net::Address & addr); | ||
126 | 126 | | |||
127 | /// Test whether or not the DB contains a key | 127 | /// Test whether or not the DB contains a key | ||
128 | bool contains(const dht::Key & key) const; | 128 | bool contains(const dht::Key & key) const; | ||
129 | 129 | | |||
130 | /// Insert an empty item (only if it isn't already in the DB) | 130 | /// Insert an empty item (only if it isn't already in the DB) | ||
131 | void insert(const dht::Key & key); | 131 | void insert(const dht::Key & key); | ||
132 | 132 | | |||
133 | private: | 133 | private: | ||
134 | bt::PtrMap<dht::Key, DBItemList> items; | 134 | bt::PtrMap<dht::Key, DBItemList> items; | ||
135 | QMap<dht::Key, bt::TimeStamp> tokens; | 135 | QMap<QByteArray, bt::TimeStamp> tokens; | ||
136 | }; | 136 | }; | ||
137 | 137 | | |||
138 | } | 138 | } | ||
139 | 139 | | |||
140 | #endif | 140 | #endif |