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