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

Fix incorrect requests to seed nodes #310

Merged
merged 1 commit into from Mar 4, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 15 additions & 5 deletions httpserver/service_node.cpp
Expand Up @@ -293,6 +293,8 @@ void ServiceNode::bootstrap_data() {
fields["block_hash"] = true;
fields["hardfork"] = true;
fields["funded"] = true;
fields["pubkey_x25519"] = true;
fields["pubkey_ed25519"] = true;

params["fields"] = fields;

Expand Down Expand Up @@ -580,18 +582,26 @@ void ServiceNode::on_bootstrap_update(const block_update_t& bu) {

void ServiceNode::on_swarm_update(const block_update_t& bu) {

// Print block update
// debug_print(std::cerr, bu);

hardfork_ = bu.hardfork;

if (syncing_ && target_height_ != 0) {
syncing_ = bu.height < target_height_;
if (syncing_) {
if (target_height_ == 0) {
// If we are here, the probably means we were never able to contact
// any seed, so the bast we can do is to assume we are synced
// (this shouldn't be necessary as we do the same when all requests
// fail, but it won't hurt either)
LOKI_LOG(info, "Target height is 0, assuming we are synced");

syncing_ = false;
} else {
syncing_ = bu.height < target_height_;
}
}

/// We don't have anything to do until we have synced
if (syncing_) {
LOKI_LOG(debug, "Still syncing: {}/{}", bu.height, target_height_);
// Note that because we are still syncing, we won't update our swarm id
return;
}

Expand Down