Skip to content

Commit

Permalink
query unknown first (#2277)
Browse files Browse the repository at this point in the history
Signed-off-by: turuslan <[email protected]>
  • Loading branch information
turuslan authored Nov 19, 2024
1 parent d86c5fe commit b046ae5
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion core/authority_discovery/query/query_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,19 @@ namespace kagome::authority_discovery {
}
}
std::shuffle(authorities.begin(), authorities.end(), random_);
queue_ = std::move(authorities);

// reorder queue to query unknown authorities first
queue_.resize(0);
queue_.reserve(authorities.size());
// `queue_` is a stack, so push known first
for (auto &known : {true, false}) {
for (auto &id : authorities) {
if (auth_to_peer_cache_.contains(id) == known) {
queue_.emplace_back(id);
}
}
}

pop();
return outcome::success();
}
Expand Down

0 comments on commit b046ae5

Please sign in to comment.