code: func (s *StanServer) leadershipLost() {
  	s.log.Noticef("server lost leadership, performing leader stepdown actions")
  	defer s.log.Noticef("finished leader stepdown actions")
  
  	// Cancel outstanding client heartbeats. We aren't concerned about races
  	// where new clients might be connecting because at this point, the server
  	// will no longer accept new client connections, but even if it did, the
  	// heartbeat would be automatically removed when it fires.
  	for _, client := range s.clients.getClients() {
  		s.clients.removeClientHB(client)
  		// Ensure subs ackTimer is stopped
  		subs := client.getSubsCopy()
  		for _, sub := range subs {
  			sub.Lock()
  			sub.stopAckSub()
  			sub.clearAckTimer()
  			s.clearSentAndAck(sub)
  			sub.Unlock()
  		}
  	}
  
  	// Unsubscribe to the snapshot request per channel since we are no longer
  	// leader.
  	for _, c := range s.channels.getAll() {
  		if c.activity != nil {
  			s.channels.stopDeleteTimer(c)
  		}
  	}
  
  	// Only the leader will receive protocols from clients
  	s.unsubscribeInternalSubs()
  
  	atomic.StoreInt64(&s.raft.leader, 0)
  }
docs: // leadershipLost should be called when this node loses leadership.
  // This should only be called when the server is running in clustered mode.