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
d44c5901
Commit
d44c5901
authored
May 27, 2016
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
network_engine: remove onNewNode return value
parent
4d75f645
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/opendht/dht.h
+1
-1
1 addition, 1 deletion
include/opendht/dht.h
include/opendht/network_engine.h
+1
-1
1 addition, 1 deletion
include/opendht/network_engine.h
src/dht.cpp
+9
-10
9 additions, 10 deletions
src/dht.cpp
with
11 additions
and
12 deletions
include/opendht/dht.h
+
1
−
1
View file @
d44c5901
...
...
@@ -440,7 +440,7 @@ private:
void
dumpBucket
(
const
Bucket
&
b
,
std
::
ostream
&
out
)
const
;
// Nodes
std
::
shared_ptr
<
Node
>
n
ewNode
(
const
std
::
shared_ptr
<
Node
>&
node
,
int
confirm
);
void
onN
ewNode
(
const
std
::
shared_ptr
<
Node
>&
node
,
int
confirm
);
std
::
shared_ptr
<
Node
>
findNode
(
const
InfoHash
&
id
,
sa_family_t
af
);
const
std
::
shared_ptr
<
Node
>
findNode
(
const
InfoHash
&
id
,
sa_family_t
af
)
const
;
bool
trySearchInsert
(
const
std
::
shared_ptr
<
Node
>&
node
);
...
...
This diff is collapsed.
Click to expand it.
include/opendht/network_engine.h
+
1
−
1
View file @
d44c5901
...
...
@@ -187,7 +187,7 @@ private:
* @param saddr_len (type: socklen_t) lenght of the sockaddr struct.
* @param confirm (type: int) 1 if the node sent a message, 2 if it sent us a reply.
*/
std
::
function
<
std
::
shared_ptr
<
Node
>
(
const
std
::
shared_ptr
<
Node
>&
,
int
)
>
onNewNode
;
std
::
function
<
void
(
const
std
::
shared_ptr
<
Node
>&
,
int
)
>
onNewNode
;
/**
* @brief when an addres is reported from a distant node.
*
...
...
This diff is collapsed.
Click to expand it.
src/dht.cpp
+
9
−
10
View file @
d44c5901
...
...
@@ -455,19 +455,19 @@ Dht::reportedAddr(const sockaddr *sa, socklen_t sa_len)
/* We just learnt about a node, not necessarily a new one. Confirm is 1 if
the node sent a message, 2 if it sent us a reply. */
std
::
shared_ptr
<
Node
>
Dht
::
n
ewNode
(
const
std
::
shared_ptr
<
Node
>&
node
,
int
confirm
)
void
Dht
::
onN
ewNode
(
const
std
::
shared_ptr
<
Node
>&
node
,
int
confirm
)
{
auto
&
list
=
node
->
getFamily
()
==
AF_INET
?
buckets
:
buckets6
;
auto
b
=
list
.
findBucket
(
node
->
id
);
if
(
b
==
list
.
end
())
return
{}
;
return
;
for
(
auto
&
n
:
b
->
nodes
)
{
if
(
n
==
node
)
{
if
(
confirm
)
trySearchInsert
(
node
);
return
n
;
return
;
}
}
...
...
@@ -490,7 +490,7 @@ Dht::newNode(const std::shared_ptr<Node>& node, int confirm)
if
(
not
n
->
isExpired
())
continue
;
n
=
node
;
return
n
;
return
;
}
if
(
b
->
nodes
.
size
()
>=
TARGET_NODES
)
{
...
...
@@ -515,7 +515,8 @@ Dht::newNode(const std::shared_ptr<Node>& node, int confirm)
DHT_LOG
.
DEBUG
(
"Splitting from depth %u"
,
list
.
depth
(
b
));
sendCachedPing
(
*
b
);
list
.
split
(
b
);
return
newNode
(
node
,
0
);
onNewNode
(
node
,
0
);
return
;
}
/* No space for this node. Cache it away for later. */
...
...
@@ -525,8 +526,6 @@ Dht::newNode(const std::shared_ptr<Node>& node, int confirm)
/* Create a new node. */
b
->
nodes
.
emplace_front
(
node
);
}
return
node
;
}
/* Called periodically to purge known-bad nodes. Note that we're very
...
...
@@ -882,7 +881,7 @@ Dht::searchStep(std::shared_ptr<Search> sr)
g
.
done_cb
(
false
,
{});
}
}
{
if
(
not
sr
->
nodes
.
empty
())
{
std
::
vector
<
DoneCallback
>
a_cbs
;
a_cbs
.
reserve
(
sr
->
announce
.
size
());
for
(
const
auto
&
a
:
sr
->
announce
)
...
...
@@ -2049,7 +2048,7 @@ Dht::Dht(int s, int s6, Config config)
:
myid
(
config
.
node_id
),
is_bootstrap
(
config
.
is_bootstrap
),
store
(),
network_engine
(
myid
,
s
,
s6
,
DHT_LOG
,
scheduler
,
std
::
bind
(
&
Dht
::
onError
,
this
,
_1
,
_2
),
std
::
bind
(
&
Dht
::
n
ewNode
,
this
,
_1
,
_2
),
std
::
bind
(
&
Dht
::
onN
ewNode
,
this
,
_1
,
_2
),
std
::
bind
(
&
Dht
::
onReportedAddr
,
this
,
_1
,
_2
,
_3
),
std
::
bind
(
&
Dht
::
onPing
,
this
,
_1
),
std
::
bind
(
&
Dht
::
onFindNode
,
this
,
_1
,
_2
,
_3
),
...
...
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