code: func (s *Server) setupRPC(tlsWrap tlsutil.DCWrapper) error {
  	for _, fn := range endpoints {
  		s.rpcServer.Register(fn(s))
  	}
  
  	ln, err := net.ListenTCP("tcp", s.config.RPCAddr)
  	if err != nil {
  		return err
  	}
  	s.Listener = ln
  	if s.config.NotifyListen != nil {
  		s.config.NotifyListen()
  	}
  	// todo(fs): we should probably guard this
  	if s.config.RPCAdvertise == nil {
  		s.config.RPCAdvertise = ln.Addr().(*net.TCPAddr)
  	}
  
  	// Verify that we have a usable advertise address
  	if s.config.RPCAdvertise.IP.IsUnspecified() {
  		ln.Close()
  		return fmt.Errorf("RPC advertise address is not advertisable: %v", s.config.RPCAdvertise)
  	}
  
  	// Provide a DC specific wrapper. Raft replication is only
  	// ever done in the same datacenter, so we can provide it as a constant.
  	wrapper := tlsutil.SpecificDC(s.config.Datacenter, tlsWrap)
  
  	// Define a callback for determining whether to wrap a connection with TLS
  	tlsFunc := func(address raft.ServerAddress) bool {
  		if s.config.VerifyOutgoing {
  			return true
  		}
  
  		server := s.serverLookup.Server(address)
  
  		if server == nil {
  			return false
  		}
  
  		return server.UseTLS
  	}
  	s.raftLayer = NewRaftLayer(s.config.RPCSrcAddr, s.config.RPCAdvertise, wrapper, tlsFunc)
  	return nil
  }
docs: // setupRPC is used to setup the RPC listener