Remove unused code

This commit is contained in:
Jeffrey Picard 2021-11-05 11:11:26 -04:00
parent c61c8db92a
commit 15614c6a5b
2 changed files with 0 additions and 35 deletions

View file

@ -116,34 +116,6 @@ func (s *Server) loadPeers() error {
return nil return nil
} }
// getFastestPeer determines the fastest peer in its list of peers by sending
// out udp pings and seeing who responds first. This is currently not
// implemented and just returns the first peer.
func (s *Server) getFastestPeer() *FederatedServer {
var fastestPeer *FederatedServer
for _, v := range s.PeerServers {
return v
}
return fastestPeer
}
// subscribeToFastestPeer is a convenience function to find and subscribe to
// the fastest peer we know about.
func (s *Server) subscribeToFastestPeer() {
peer := s.getFastestPeer()
if peer != nil {
err := s.subscribeToPeer(peer)
if err != nil {
log.Println(err)
}
} else {
log.Println("No peers found, not subscribed to any.")
}
}
// subscribeToPeer subscribes us to a peer to we'll get updates about their // subscribeToPeer subscribes us to a peer to we'll get updates about their
// known peers. // known peers.
func (s *Server) subscribeToPeer(peer *FederatedServer) error { func (s *Server) subscribeToPeer(peer *FederatedServer) error {

View file

@ -219,17 +219,10 @@ func MakeHubServer(ctx context.Context, args *Args) *Server {
} }
// Load peers from disk and subscribe to one if there are any // Load peers from disk and subscribe to one if there are any
if args.LoadPeers { if args.LoadPeers {
// We Subscribed to true, so we don't try subscribing to peers as we
// add them, we'll find the best one after
s.Subscribed = true
err = s.loadPeers() err = s.loadPeers()
if err != nil { if err != nil {
log.Println(err) log.Println(err)
} }
// subscribe to the fastest peer we know (if there are any) for updates
// about their peers.
s.Subscribed = false
s.subscribeToFastestPeer()
} }
return s return s