p2p: simplify checkpoint handling

There is no need to select on srv.quit for both ends of the checkpoint channel.
This commit is contained in:
Felix Lange 2019-06-07 13:37:21 +02:00
parent 3be913743a
commit 3b6d9788d5

View file

@ -731,11 +731,8 @@ running:
c.flags |= trustedConn
}
// TODO: track in-progress inbound node IDs (pre-Peer) to avoid dialing them.
select {
case c.cont <- srv.postHandshakeChecks(peers, inboundCount, c):
case <-srv.quit:
break running
}
c.cont <- srv.postHandshakeChecks(peers, inboundCount, c)
case c := <-srv.checkpointAddPeer:
// At this point the connection is past the protocol handshake.
// Its capabilities are known and the remote identity is verified.
@ -759,11 +756,7 @@ running:
// The dialer logic relies on the assumption that
// dial tasks complete after the peer has been added or
// discarded. Unblock the task last.
select {
case c.cont <- err:
case <-srv.quit:
break running
}
c.cont <- err
case pd := <-srv.delpeer:
// A peer disconnected.
@ -1012,12 +1005,7 @@ func (srv *Server) checkpoint(c *conn, stage chan<- *conn) error {
case <-srv.quit:
return errServerStopped
}
select {
case err := <-c.cont:
return err
case <-srv.quit:
return errServerStopped
}
return <-c.cont
}
// runPeer runs in its own goroutine for each peer.