Process head_chains in descending order of number of peers (#8859)

N/A


  Another find by @gitToki. Sort the preferred_ids in descending order as originally intended from the comment in the function.


Co-Authored-By: Pawan Dhananjay <pawandhananjay@gmail.com>
This commit is contained in:
Pawan Dhananjay
2026-02-19 06:08:56 +05:30
committed by GitHub
parent be799cb2ad
commit 561898fc1c

View File

@@ -351,7 +351,8 @@ impl<T: BeaconChainTypes> ChainCollection<T> {
.iter()
.map(|(id, chain)| (chain.available_peers(), !chain.is_syncing(), *id))
.collect::<Vec<_>>();
preferred_ids.sort_unstable();
// Sort in descending order
preferred_ids.sort_unstable_by(|a, b| b.cmp(a));
let mut syncing_chains = SmallVec::<[Id; PARALLEL_HEAD_CHAINS]>::new();
for (_, _, id) in preferred_ids {