Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
opendht
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
opendht
Commits
00ef6609
Commit
00ef6609
authored
8 years ago
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
dht: hide more internal structures
parent
862a0371
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/opendht/dht.h
+6
-66
6 additions, 66 deletions
include/opendht/dht.h
src/dht.cpp
+61
-0
61 additions, 0 deletions
src/dht.cpp
with
67 additions
and
66 deletions
include/opendht/dht.h
+
6
−
66
View file @
00ef6609
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
src/dht.cpp
+
61
−
0
View file @
00ef6609
...
@@ -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
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment