-
Notifications
You must be signed in to change notification settings - Fork 172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
re-publish and re-discover immediately when the node disconnects #713
Conversation
… connectivity changes.
…sconnects, instead of on the connectivityChanged signal.
src/dhtrunner.cpp
Outdated
@@ -690,8 +696,13 @@ DhtRunner::loop_() | |||
if (nstatus4 != status4 || nstatus6 != status6) { | |||
status4 = nstatus4; | |||
status6 = nstatus6; | |||
if (statusCb) | |||
statusCb(status4, status6); | |||
if (!statusCbs.empty()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if not needed
src/dhtrunner.cpp
Outdated
if (!statusCbs.empty()) | ||
{ | ||
for (auto& cb : statusCbs){ | ||
if (cb) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check not needed
src/dhtrunner.cpp
Outdated
statusCb = std::move(context.statusChangedCallback); | ||
} | ||
statusCbs.clear(); | ||
statusCbs.emplace_back(std::move(context.statusChangedCallback)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only emplace if statusChangedCallback
is not {}
.
include/opendht/dhtrunner.h
Outdated
@@ -519,7 +519,8 @@ class OPENDHT_PUBLIC DhtRunner { | |||
|
|||
NodeStatus status4 {NodeStatus::Disconnected}, | |||
status6 {NodeStatus::Disconnected}; | |||
StatusCallback statusCb {nullptr}; | |||
|
|||
std::list<StatusCallback> statusCbs {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could be a vector
include/opendht/dhtrunner.h
Outdated
@@ -409,7 +409,7 @@ class OPENDHT_PUBLIC DhtRunner { | |||
void run(const Config& config, Context&& context); | |||
|
|||
void setOnStatusChanged(StatusCallback&& cb) { | |||
statusCb = std::move(cb); | |||
statusCbs.emplace_back(std::move(cb)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
emplace if not empty
src/dhtrunner.cpp
Outdated
@@ -264,6 +263,13 @@ DhtRunner::run(const Config& config, Context&& context) | |||
} | |||
} | |||
} | |||
if (config.peer_discovery && config.peer_publish) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if only peer_discovery
or peer_publish
is true ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be config.peer_discovery or config.peer_publish
so i changed it to if (peerDiscovery_)
.
No description provided.