Skip to content

Commit

Permalink
syncer: prioritize peers that support V2 RPCs
Browse files Browse the repository at this point in the history
  • Loading branch information
peterjan committed May 22, 2024
1 parent cbe0215 commit 70ddacd
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions syncer/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"net"
"sort"
"sync"
"time"

Expand Down Expand Up @@ -529,9 +530,13 @@ func (s *Syncer) syncLoop() error {
if p.Synced() {
continue
}
if peers = append(peers, p); len(peers) >= 3 {
break
}
peers = append(peers, p)
}
sort.Slice(peers, func(i, j int) bool {
return peers[i].t.SupportsV2() && !peers[j].t.SupportsV2()
})
if len(peers) > 3 {
peers = peers[:3]
}
return
}
Expand Down

0 comments on commit 70ddacd

Please sign in to comment.