// RegPromotions registers this listener to listen for promotions.
7871
func (el *ChannelEventListener) RegPromotions() *ChannelEventListener {
	el.Promoted = make(chan *promoter.PromotionReattachmentEvent)
	el.ids = append(el.ids, el.em.RegisterListener(func(data interface{}) {
		el.Promoted <- data.(*promoter.PromotionReattachmentEvent)
	}, promoter.EventPromotion))
	return el
}
916864
func (l *LightningWallet) ActiveReservations() []*ChannelReservation {
	reservations := make([]*ChannelReservation, 0, len(l.fundingLimbo))
	for _, reservation := range l.fundingLimbo {
		reservations = append(reservations, reservation)
	}

	return reservations
}
1089740
func (t *compactionTracker) DecActive(level compactionLevel) {
	atomic.AddUint64(&t.active[level], ^uint64(0))

	labels := t.Labels(level)
	t.metrics.CompactionsActive.With(labels).Dec()
}
503482
func RestrictDelegationPathPrefixes(parentPaths, delegationPaths []string) []string {
	validPaths := []string{}
	if len(delegationPaths) == 0 {
		return validPaths
	}

	// Validate each individual delegation path
	for _, delgPath := range delegationPaths {
		isPrefixed := false
		for _, parentPath := range parentPaths {
			if strings.HasPrefix(delgPath, parentPath) {
				isPrefixed = true
				break
			}
		}
		// If the delegation path did not match prefix against any parent path, it is not valid
		if isPrefixed {
			validPaths = append(validPaths, delgPath)
		}
	}
	return validPaths
}
353420
func (el *CallbackEventListener) RegInputSelection(f BoolEventCallback) {
	el.ids = append(el.ids, el.em.RegisterListener(func(data interface{}) {
		f(data.(bool))
	}, event.EventDoingInputSelection))
}
779096
func (s *flunderLister) Flunders(namespace string) FlunderNamespaceLister {
	return flunderNamespaceLister{indexer: s.indexer, namespace: namespace}
}
1269955
func activeChannels(subs []*Subscriber, pat string) []string {
	channels := map[string]struct{}{}
	for _, s := range subs {
		for c := range s.channels {
			channels[c] = struct{}{}
		}
	}

	var cpat *regexp.Regexp
	if pat != "" {
		cpat = compileChannelPattern(pat)
	}

	var cs []string
	for k := range channels {
		if cpat != nil && !cpat.MatchString(k) {
			continue
		}
		cs = append(cs, k)
	}
	sort.Strings(cs)
	return cs
}
1089791
func (pkz privKeys) ToValidators(init, inc int64) *types.ValidatorSet {
	res := make([]*types.Validator, len(pkz))
	for i, k := range pkz {
		res[i] = types.NewValidator(k.PubKey(), init+int64(i)*inc)
	}
	return types.NewValidatorSet(res)
}
1123743
func (r *Store) GitAddRemote(ctx context.Context, name, remote, url string) error {
	ctx, store, _ := r.getStore(ctx, name)
	return store.RCS().AddRemote(ctx, remote, url)
}
332621
func (el *ChannelEventListener) RegReattachments() *ChannelEventListener {
	el.Reattached = make(chan *promoter.PromotionReattachmentEvent)
	el.ids = append(el.ids, el.em.RegisterListener(func(data interface{}) {
		el.Reattached <- data.(*promoter.PromotionReattachmentEvent)
	}, promoter.EventReattachment))
	return el
}
1220510
func NewPromoter(setts *account.Settings, interval time.Duration) *Promoter {
	if setts.EventMachine == nil {
		setts.EventMachine = &event.DiscardEventMachine{}
	}
	promoter := &Promoter{
		interval: interval, setts: setts,
		tailCache: make(map[string]*transaction.Transaction),
	}
	promoter.syncTimer = util.NewSyncIntervalTimer(interval, promoter.promote, func(err error) {
		promoter.setts.EventMachine.Emit(err, event.EventError)
	})
	return promoter
}
723835
func (a *Autopilot) handlePromotions(promotions []raft.Server) error {
	// This used to wait to only promote to maintain an odd quorum of
	// servers, but this was at odds with the dead server cleanup when doing
	// rolling updates (add one new server, wait, and then kill an old
	// server). The dead server cleanup would still count the old server as
	// a peer, which is conservative and the right thing to do, and this
	// would wait to promote, so you could get into a stalemate. It is safer
	// to promote early than remove early, so by promoting as soon as
	// possible we have chosen that as the solution here.
	for _, server := range promotions {
		a.logger.Printf("[INFO] autopilot: Promoting %s to voter", fmtServer(server))
		addFuture := a.delegate.Raft().AddVoter(server.ID, server.Address, 0, 0)
		if err := addFuture.Error(); err != nil {
			return fmt.Errorf("failed to add raft peer: %v", err)
		}
	}

	// If we promoted a server, trigger a check to remove dead servers.
	if len(promotions) > 0 {
		select {
		case a.removeDeadCh <- struct{}{}:
		default:
		}
	}
	return nil
}
960766
func (router *Router) addRegexpRoute(method HTTPMethod, path string, pathCompiled *regexp.Regexp, handler http.HandlerFunc) *Router {
	if _, ok := router.regexps[method]; !ok {
		router.regexps[method] = map[*regexp.Regexp]http.HandlerFunc{}
	}
	router.regexps[method][pathCompiled] = handler
	return router
}
792475
func WriteMethods() []*regexp.Regexp {
	return []*regexp.Regexp{
		regexp.MustCompile(baseMethod + "NewCharge"),
		regexp.MustCompile(baseMethod + "RefundCharge"),
	}
}
167345
func (d *API) AuthenticatorsFor(schemes map[string]spec.SecurityScheme) map[string]runtime.Authenticator {
	result := make(map[string]runtime.Authenticator)
	for k := range schemes {
		if a, ok := d.authenticators[k]; ok {
			result[k] = a
		}
	}
	return result
}
347731
func (s *Swarm) ListenAddresses() []ma.Multiaddr {
	s.listeners.RLock()
	defer s.listeners.RUnlock()
	addrs := make([]ma.Multiaddr, 0, len(s.listeners.m))
	for l := range s.listeners.m {
		addrs = append(addrs, l.Multiaddr())
	}
	return addrs
}
599217
func (el *ChannelEventListener) RegInputSelection() *ChannelEventListener {
	el.ExecutingInputSelection = make(chan bool)
	el.ids = append(el.ids, el.em.RegisterListener(func(data interface{}) {
		el.ExecutingInputSelection <- data.(bool)
	}, event.EventDoingInputSelection))
	return el
}