Skip to content
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

Merged
merged 3 commits into from
Jun 25, 2024

Conversation

AmnaSnene
Copy link
Contributor

No description provided.

@@ -690,8 +696,13 @@ DhtRunner::loop_()
if (nstatus4 != status4 || nstatus6 != status6) {
status4 = nstatus4;
status6 = nstatus6;
if (statusCb)
statusCb(status4, status6);
if (!statusCbs.empty())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if not needed

if (!statusCbs.empty())
{
for (auto& cb : statusCbs){
if (cb)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check not needed

statusCb = std::move(context.statusChangedCallback);
}
statusCbs.clear();
statusCbs.emplace_back(std::move(context.statusChangedCallback));
Copy link
Member

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 {}.

@@ -519,7 +519,8 @@ class OPENDHT_PUBLIC DhtRunner {

NodeStatus status4 {NodeStatus::Disconnected},
status6 {NodeStatus::Disconnected};
StatusCallback statusCb {nullptr};

std::list<StatusCallback> statusCbs {};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could be a vector

@@ -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));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

emplace if not empty

@@ -264,6 +263,13 @@ DhtRunner::run(const Config& config, Context&& context)
}
}
}
if (config.peer_discovery && config.peer_publish) {
Copy link
Member

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 ?

Copy link
Contributor Author

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_).

@aberaud aberaud merged commit 3e2fd5e into savoirfairelinux:master Jun 25, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants