// Advertise advertises this node as a libp2p relay.
173593
func Advertise(ctx context.Context, advertise discovery.Advertiser) {
	go func() {
		select {
		case <-time.After(AdvertiseBootDelay):
			discovery.Advertise(ctx, advertise, RelayRendezvous)
		case <-ctx.Done():
		}
	}()
}
365284
func (c *Chain) AddNode(nodes ...Node) {
	if c == nil {
		return
	}
	for _, node := range nodes {
		c.nodeGroups = append(c.nodeGroups, NewNodeGroup(node))
	}
}
636327
func (m *Mercury) AddNode(ctx context.Context, name, endpoint, podname, ca, cert, key string, cpu, share int, memory int64, labels map[string]string) (*types.Node, error) {
	// TODO VM branch
	if !strings.HasPrefix(endpoint, nodeTCPPrefixKey) &&
		!strings.HasPrefix(endpoint, nodeSockPrefixKey) &&
		!strings.HasPrefix(endpoint, nodeMockPrefixKey) {
		return nil, types.NewDetailedErr(types.ErrNodeFormat,
			fmt.Sprintf("endpoint must starts with %s or %s %q",
				nodeTCPPrefixKey, nodeSockPrefixKey, endpoint))
	}

	_, err := m.GetPod(ctx, podname)
	if err != nil {
		return nil, err
	}

	if _, err := m.doGetNode(ctx, podname, name); err == nil {
		return nil, types.NewDetailedErr(types.ErrNodeExist,
			fmt.Sprintf("node %s:%s already exists",
				podname, name))
	}

	// 尝试加载的客户端
	// 会自动判断是否是支持的 url
	engine, err := m.doMakeClient(ctx, name, endpoint, ca, cert, key)
	if err != nil {
		return nil, err
	}

	// 判断这货是不是活着的
	info, err := engine.Info(ctx)
	if err != nil {
		return nil, err
	}
	// 更新默认值
	if cpu == 0 {
		cpu = info.NCPU
	}
	if memory == 0 {
		memory = info.MemTotal - types.GByte
	}
	if share == 0 {
		share = m.config.Scheduler.ShareBase
	}

	return m.doAddNode(ctx, name, endpoint, podname, ca, cert, key, cpu, share, memory, labels)
}
580213
func (s *server) NotifyWhenOnline(peerKey *btcec.PublicKey,
	peerChan chan<- lnpeer.Peer) {

	s.mu.Lock()
	defer s.mu.Unlock()

	// Compute the target peer's identifier.
	pubStr := string(peerKey.SerializeCompressed())

	// Check if peer is connected.
	peer, ok := s.peersByPub[pubStr]
	if ok {
		// Connected, can return early.
		srvrLog.Debugf("Notifying that peer %x is online",
			peerKey.SerializeCompressed())

		select {
		case peerChan <- peer:
		case <-s.quit:
		}

		return
	}

	// Not connected, store this listener such that it can be notified when
	// the peer comes online.
	s.peerConnectedListeners[pubStr] = append(
		s.peerConnectedListeners[pubStr], peerChan,
	)
}
875500
func (n *Node) newAdvertisement() *advertisement {
	return &advertisement{
		VersionType: vrrpVersionType,
		VRID:        n.VRID,
		Priority:    n.Priority,
		AdvertInt:   uint16(n.MasterAdvertInterval / time.Millisecond / 10), // AdvertInt is in centiseconds
	}
}
165536
func (payload *rateBottlePayload) Publicize() *RateBottlePayload {
	var pub RateBottlePayload
	if payload.Rating != nil {
		pub.Rating = *payload.Rating
	}
	return &pub
}
337684
func (h *HCI) AdvertiseIBeacon(u ble.UUID, major, minor uint16, pwr int8) error {
	ad, err := adv.NewPacket(adv.IBeacon(u, major, minor, pwr))
	if err != nil {
		return err
	}
	if err := h.SetAdvertisement(ad.Bytes(), nil); err != nil {
		return nil
	}
	return h.Advertise()
}
754561
func (remote *RemoteDebugger) RequestNode(nodeID int) error {
	_, err := remote.SendRequest("DOM.requestChildNodes", Params{
		"nodeId": nodeID,
	})

	return err
}
740087
func (rb *RingBuffer) Offer(item interface{}) (bool, error) {
	return rb.put(item, true)
}
449026
func (nc *nccClient) BGPAdvertiseVIP(vip net.IP) error {
	return nc.call("SeesawNCC.BGPAdvertiseVIP", vip, nil)
}
821865
func (h *connectionHeap) Offer(conn *Connection, hint byte) bool {
	idx := int(hint) % len(h.heaps)
	end := idx + len(h.heaps)
	for i := idx; i < end; i++ {
		if h.heaps[i%len(h.heaps)].Offer(conn) {
			// success
			return true
		}
	}
	return false
}
1308186
func (h *HCI) StopAdvertising() error {
	h.params.advEnable.AdvertisingEnable = 0
	return h.Send(&h.params.advEnable, nil)
}
1181523
func (n *Node) doRaftAddPeer(conn redcon.Conn, cmd redcon.Command) (interface{}, error) {
	if len(cmd.Args) != 2 {
		return nil, ErrWrongNumberOfArguments
	}
	n.log.Noticef("Received add peer request from %v", string(cmd.Args[1]))
	f := n.raft.AddPeer(string(cmd.Args[1]))
	if f.Error() != nil {
		return nil, f.Error()
	}
	n.log.Noticef("Node %v added successfully", string(cmd.Args[1]))
	conn.WriteString("OK")
	return nil, nil
}
537528
func (l *LightningNode) NodeAnnouncement(signed bool) (*lnwire.NodeAnnouncement,
	error) {

	if !l.HaveNodeAnnouncement {
		return nil, fmt.Errorf("node does not have node announcement")
	}

	alias, err := lnwire.NewNodeAlias(l.Alias)
	if err != nil {
		return nil, err
	}

	nodeAnn := &lnwire.NodeAnnouncement{
		Features:        l.Features.RawFeatureVector,
		NodeID:          l.PubKeyBytes,
		RGBColor:        l.Color,
		Alias:           alias,
		Addresses:       l.Addresses,
		Timestamp:       uint32(l.LastUpdate.Unix()),
		ExtraOpaqueData: l.ExtraOpaqueData,
	}

	if !signed {
		return nodeAnn, nil
	}

	sig, err := lnwire.NewSigFromRawSignature(l.AuthSigBytes)
	if err != nil {
		return nil, err
	}

	nodeAnn.Signature = sig

	return nodeAnn, nil
}
390946
func (c *Client) CreateNode(config *adapters.NodeConfig) (*p2p.NodeInfo, error) {
	node := &p2p.NodeInfo{}
	return node, c.Post("/nodes", config, node)
}
405193
func promote2(l, r *Type) *Type {
	l = promote1(l)
	r = promote1(r)

	// if mixed signedness, make l signed and r unsigned.
	// specifically, if l is unsigned, swap with r.
	if (l.Kind-Char)&1 == 1 {
		l, r = r, l
	}

	switch {
	case l.Kind == Void || r.Kind == Void || l.Kind > Double || r.Kind > Double:
		return nil
	case l.Kind == r.Kind:
		return l
	// double wins.
	case l.Kind == Double:
		return l
	case r.Kind == Double:
		return r
	// float wins.
	case l.Kind == Float:
		return l
	case r.Kind == Float:
		return r
	// if both signed or both unsigned, higher kind wins.
	case (l.Kind-Char)&1 == (r.Kind-Char)&1:
		if l.Kind < r.Kind {
			return r
		}
		return l
	// mixed signedness: l is signed, r is unsigned (see above).
	// if unsigned higher kind than signed, unsigned wins.
	case r.Kind >= l.Kind:
		return r
	// signed is higher kind than unsigned (l.Kind > r.Kind).
	// if signed bigger than unsigned, signed wins.
	// only possible way this isn't true
	case (l.Kind-Char)/2 > (r.Kind-Char)/2 && (l.Kind != Long || r.Kind != Uint):
		return l
	// otherwise, use unsigned type corresponding to the signed type.
	default:
		return &Type{Kind: l.Kind + 1}
	}
	panic(fmt.Sprintf("missing case in promote2(%v, %v)", l, r))
}
1085978
func (c *clientAdvertiseOption) Apply(server *Server) {
	server.mu.Lock()
	server.setInfoHostPortAndGenerateJSON()
	server.mu.Unlock()
	server.Noticef("Reload: client_advertise = %s", c.newValue)
}