Skip to content

Commit

Permalink
Merge branch 'block-generation' into perfnet
Browse files Browse the repository at this point in the history
  • Loading branch information
SpyCheese committed Jul 26, 2023
2 parents 20c2e5a + 503e10c commit 28a42a7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion validator/full-node-shard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1190,6 +1190,10 @@ const Neighbour &FullNodeShardImpl::choose_neighbour(bool require_state) const {
return Neighbour::zero;
}

double min_unreliability = 1e9;
for (auto &x : neighbours_) {
min_unreliability = std::min(min_unreliability, x.second.unreliability);
}
for (int attempt = 0; attempt < (require_state ? 2 : 1); ++attempt) {
const Neighbour *best = nullptr;
td::uint32 sum = 0;
Expand All @@ -1203,7 +1207,7 @@ const Neighbour &FullNodeShardImpl::choose_neighbour(bool require_state) const {
continue;
}
}
auto unr = static_cast<td::uint32>(x.second.unreliability);
auto unr = static_cast<td::uint32>(x.second.unreliability - min_unreliability);

if (x.second.proto_version < proto_version()) {
unr += 4;
Expand Down

0 comments on commit 28a42a7

Please sign in to comment.