Skip to content
Snippets Groups Projects
Commit 00ef6609 authored by Adrien Béraud's avatar Adrien Béraud
Browse files

dht: hide more internal structures

parent 862a0371
No related branches found
No related tags found
No related merge requests found
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
#pragma once #pragma once
#include "infohash.h" #include "infohash.h"
...@@ -33,10 +32,7 @@ ...@@ -33,10 +32,7 @@
#include <array> #include <array>
#include <vector> #include <vector>
#include <map> #include <map>
#include <list>
#include <queue>
#include <functional> #include <functional>
#include <algorithm>
#include <memory> #include <memory>
#ifdef _WIN32 #ifdef _WIN32
...@@ -319,70 +315,14 @@ private: ...@@ -319,70 +315,14 @@ private:
static constexpr size_t TOKEN_SIZE {64}; static constexpr size_t TOKEN_SIZE {64};
// internal structures
struct SearchNode; struct SearchNode;
struct Get;
/** struct Announce;
* A single "get" operation data struct LocalListener;
*/
struct Get {
time_point start;
Value::Filter filter;
std::shared_ptr<Query> query;
std::set<std::shared_ptr<Query>> pagination_queries;
QueryCallback query_cb;
GetCallback get_cb;
DoneCallback done_cb;
};
/**
* A single "put" operation data
*/
struct Announce {
bool permanent;
std::shared_ptr<Value> value;
time_point created;
DoneCallback callback;
};
/**
* A single "listen" operation data
*/
struct LocalListener {
std::shared_ptr<Query> query;
Value::Filter filter;
GetCallback get_cb;
};
/**
* A search is a list of the nodes we think are responsible
* for storing values for a given hash.
*/
struct Search; struct Search;
struct ValueStorage;
struct ValueStorage { struct Listener;
std::shared_ptr<Value> data {};
time_point time {};
ValueStorage() {}
ValueStorage(const std::shared_ptr<Value>& v, time_point t) : data(v), time(t) {}
};
/**
* Foreign nodes asking for updates about an InfoHash.
*/
struct Listener {
size_t rid {};
time_point time {};
Query query {};
/*constexpr*/ Listener(size_t rid, time_point t, Query&& q) : rid(rid), time(t), query(q) {}
void refresh(size_t tid, time_point t) {
rid = tid;
time = t;
}
};
struct Storage; struct Storage;
// prevent copy // prevent copy
......
...@@ -91,6 +91,30 @@ constexpr std::chrono::seconds Dht::REANNOUNCE_MARGIN; ...@@ -91,6 +91,30 @@ constexpr std::chrono::seconds Dht::REANNOUNCE_MARGIN;
// internal structures definition // internal structures definition
/**
* Foreign nodes asking for updates about an InfoHash.
*/
struct Dht::Listener {
size_t rid {};
time_point time {};
Query query {};
/*constexpr*/ Listener(size_t rid, time_point t, Query&& q) : rid(rid), time(t), query(q) {}
void refresh(size_t tid, time_point t) {
rid = tid;
time = t;
}
};
struct Dht::ValueStorage {
std::shared_ptr<Value> data {};
time_point time {};
ValueStorage() {}
ValueStorage(const std::shared_ptr<Value>& v, time_point t) : data(v), time(t) {}
};
struct Dht::Storage { struct Dht::Storage {
InfoHash id; InfoHash id;
time_point maintenance_time {}; time_point maintenance_time {};
...@@ -170,6 +194,39 @@ private: ...@@ -170,6 +194,39 @@ private:
size_t total_size {}; size_t total_size {};
}; };
/**
* A single "get" operation data
*/
struct Dht::Get {
time_point start;
Value::Filter filter;
std::shared_ptr<Query> query;
std::set<std::shared_ptr<Query>> pagination_queries;
QueryCallback query_cb;
GetCallback get_cb;
DoneCallback done_cb;
};
/**
* A single "put" operation data
*/
struct Dht::Announce {
bool permanent;
std::shared_ptr<Value> value;
time_point created;
DoneCallback callback;
};
/**
* A single "listen" operation data
*/
struct Dht::LocalListener {
std::shared_ptr<Query> query;
Value::Filter filter;
GetCallback get_cb;
};
struct Dht::SearchNode { struct Dht::SearchNode {
using AnnounceStatus = std::map<Value::Id, std::shared_ptr<Request>>; using AnnounceStatus = std::map<Value::Id, std::shared_ptr<Request>>;
using SyncStatus = std::map<std::shared_ptr<Query>, std::shared_ptr<Request>>; using SyncStatus = std::map<std::shared_ptr<Query>, std::shared_ptr<Request>>;
...@@ -377,6 +434,10 @@ struct Dht::SearchNode { ...@@ -377,6 +434,10 @@ struct Dht::SearchNode {
} }
}; };
/**
* A search is a list of the nodes we think are responsible
* for storing values for a given hash.
*/
struct Dht::Search { struct Dht::Search {
InfoHash id {}; InfoHash id {};
sa_family_t af; sa_family_t af;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment