func attemptConnectionToPeer(address string, cm *network.ConnectionManager) { c, err := tls.Dial(address) if err != nil { log.Printf("Error trying to connect to %v : %v", address, err) } else { cm.Handle(c) } }
func ReportStats(db *database.TorrentDB, cm *network.ConnectionManager) { for range time.Tick(time.Minute) { c := make(chan string) go db.GetTorrents(c) count := 0 for range c { count += 1 } log.Printf("TorrentDB(%d torrents) PeerManager(%d peers)", count, cm.NumPeers()) } }