code: func (s *ticketStore) removeTicketRef(ref ticketRef) {
  	log.Trace("Removing discovery ticket reference", "node", ref.t.node.ID, "serial", ref.t.serial)
  
  	// Make nextRegisterableTicket return the next available ticket.
  	s.nextTicketCached = nil
  
  	topic := ref.topic()
  	tickets := s.tickets[topic]
  
  	if tickets == nil {
  		log.Trace("Removing tickets from unknown topic", "topic", topic)
  		return
  	}
  	bucket := timeBucket(ref.t.regTime[ref.idx] / mclock.AbsTime(ticketTimeBucketLen))
  	list := tickets.buckets[bucket]
  	idx := -1
  	for i, bt := range list {
  		if bt.t == ref.t {
  			idx = i
  			break
  		}
  	}
  	if idx == -1 {
  		panic(nil)
  	}
  	list = append(list[:idx], list[idx+1:]...)
  	if len(list) != 0 {
  		tickets.buckets[bucket] = list
  	} else {
  		delete(tickets.buckets, bucket)
  	}
  	ref.t.refCnt--
  	if ref.t.refCnt == 0 {
  		delete(s.nodes, ref.t.node)
  		delete(s.nodeLastReq, ref.t.node)
  	}
  }
docs: // removeTicket removes a ticket from the ticket store