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
5277b8d2
Commit
5277b8d2
authored
8 years ago
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
dht: storage refresh returns bool
parent
86fea491
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/dht.cpp
+12
-11
12 additions, 11 deletions
src/dht.cpp
with
12 additions
and
11 deletions
src/dht.cpp
+
12
−
11
View file @
5277b8d2
...
...
@@ -185,15 +185,17 @@ struct Dht::Storage {
/**
* Refreshes the time point of the value's lifetime begining.
*
* @param now The reference to now;
* @param vid The value id;
* @param now The reference to now
* @param vid The value id
* @return true if a value storage was updated, false otherwise
*/
void
refresh
(
const
time_point
&
now
,
const
Value
::
Id
&
vid
)
{
auto
vs
=
std
::
find_if
(
values
.
begin
(),
values
.
end
(),
[
&
vid
](
const
ValueStorage
&
vs
)
{
return
vs
.
data
->
id
==
vid
;
});
if
(
vs
!=
values
.
end
())
vs
->
time
=
now
;
bool
refresh
(
const
time_point
&
now
,
const
Value
::
Id
&
vid
)
{
for
(
auto
&
vs
:
values
)
if
(
vs
.
data
->
id
==
vid
)
{
vs
.
time
=
now
;
return
true
;
}
return
false
;
}
std
::
pair
<
ssize_t
,
ssize_t
>
expire
(
const
std
::
map
<
ValueType
::
Id
,
ValueType
>&
types
,
time_point
now
);
...
...
@@ -3338,9 +3340,8 @@ Dht::onRefresh(std::shared_ptr<Node> node, const InfoHash& hash, const Blob& tok
}
auto
s
=
store
.
find
(
hash
);
if
(
s
!=
store
.
end
())
{
DHT_LOG
.
DEBUG
(
"[Storage %s] refreshed value (vid: %d)."
,
hash
.
toString
().
c_str
(),
vid
);
s
->
second
.
refresh
(
now
,
vid
);
if
(
s
!=
store
.
end
()
and
s
->
second
.
refresh
(
now
,
vid
))
{
DHT_LOG
.
DEBUG
(
"[store %s] refreshed value %s."
,
hash
.
toString
().
c_str
(),
std
::
to_string
(
vid
).
c_str
());
}
else
{
DHT_LOG
.
DEBUG
(
"[node %s] got refresh value for unknown storage (id: %s)."
,
node
->
id
.
toString
().
c_str
(),
...
...
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