zcash: time out underlying TCP connection

This commit is contained in:
George Tankersley 2019-10-17 00:54:23 -04:00
parent fdb8953ac2
commit 6b0ca0e25a
1 changed files with 3 additions and 4 deletions

View File

@ -216,8 +216,7 @@ func (s *Seeder) Connect(addr, port string) error {
return ErrRepeatConnection
}
// TODO time out
conn, err := net.Dial("tcp", p.Addr())
conn, err := net.DialTimeout("tcp", p.Addr(), 1*time.Second)
if err != nil {
return errors.Wrap(err, "dialing new peer address")
}
@ -234,8 +233,8 @@ func (s *Seeder) Connect(addr, port string) error {
s.logger.Printf("Handshake completed with new peer %s", p.Addr())
s.handshakeSignals.Delete(p.Addr())
return nil
case <-time.After(time.Second * 1):
return errors.New("peer handshake timed out")
case <-time.After(1 * time.Second):
return errors.New("peer handshake started but timed out")
}
panic("This should be unreachable")