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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
opendht
Commits
00676c16
Unverified
Commit
00676c16
authored
8 years ago
by
Adrien Béraud
Committed by
Simon Désaulniers
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
dht: add code documentation
parent
fba2f0a3
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/dht.cpp
+29
-4
29 additions, 4 deletions
src/dht.cpp
with
29 additions
and
4 deletions
src/dht.cpp
+
29
−
4
View file @
00676c16
...
...
@@ -184,6 +184,11 @@ struct Dht::SearchNode {
return
not
node
->
isExpired
()
and
not
token
.
empty
()
and
last_get_reply
>=
now
-
Node
::
NODE_EXPIRE_TIME
;
}
/**
* Could a "get" request be sent to this node now ?
* update: time of the last "get" op for the search.
*/
bool
canGet
(
time_point
now
,
time_point
update
)
const
{
return
not
node
->
isExpired
()
and
(
now
>
last_get_reply
+
Node
::
NODE_EXPIRE_TIME
or
update
>
last_get_reply
)
...
...
@@ -204,6 +209,9 @@ struct Dht::SearchNode {
return
listenStatus
->
reply_time
+
LISTEN_EXPIRE_TIME
>
now
;
}
/**
* Assumng the node is synced, should a "put" request be sent to this node now ?
*/
time_point
getAnnounceTime
(
AnnounceStatusMap
::
const_iterator
ack
,
const
ValueType
&
type
)
const
{
if
(
ack
==
acked
.
end
()
or
not
ack
->
second
)
return
time_point
::
min
();
...
...
@@ -214,12 +222,19 @@ struct Dht::SearchNode {
return
getAnnounceTime
(
acked
.
find
(
vid
),
type
);
}
/**
* Assumng the node is synced, should a "listen" request be sent to this node now ?
*/
time_point
getListenTime
()
const
{
if
(
not
listenStatus
)
return
time_point
::
min
();
return
listenStatus
->
pending
()
?
time_point
::
max
()
:
listenStatus
->
reply_time
+
LISTEN_EXPIRE_TIME
-
REANNOUNCE_MARGIN
;
}
/**
* Is this node expired or candidate
*/
bool
isBad
()
const
{
return
!
node
||
node
->
isExpired
()
||
candidate
;
}
...
...
@@ -290,6 +305,10 @@ struct Dht::Search {
*/
bool
isSynced
(
time_point
now
)
const
;
/**
* Get the time of the last "get" operation performed on this search,
* or time_point::min() if no such operation have been performed.
*/
time_point
getLastGetTime
()
const
;
/**
...
...
@@ -308,17 +327,23 @@ struct Dht::Search {
unsigned
getNumberOfBadNodes
()
const
;
/**
* ret = 0 : no announce required.
* ret > 0 : (re-)announce required at time ret.
* Returns the time of the next "announce" event for this search,
* or time_point::max() if no such event is planned.
* Only makes sense when the search is synced.
*/
time_point
getAnnounceTime
(
const
std
::
map
<
ValueType
::
Id
,
ValueType
>&
types
,
time_point
now
)
const
;
/**
* ret = 0 : no listen required.
* ret > 0 : (re-)announce required at time ret.
* Returns the time of the next "listen" event for this search,
* or time_point::max() if no such event is planned.
* Only makes sense when the search is synced.
*/
time_point
getListenTime
(
time_point
now
)
const
;
/**
* Returns the time of the next event for this search,
* or time_point::max() if no such event is planned.
*/
time_point
getNextStepTime
(
const
std
::
map
<
ValueType
::
Id
,
ValueType
>&
types
,
time_point
now
)
const
;
bool
removeExpiredNode
(
time_point
now
);
...
...
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