// AddClientRef appends the client's digest given as ObjectRef.
//
// Returns an error (platform, hash algo) combination has already been added or
// the hash is unrecognized.
515387
func (d *ClientDigestsFile) AddClientRef(plat string, ref *api.ObjectRef) error {
	if err := common.ValidateObjectRef(ref, common.KnownHash); err != nil {
		return err
	}
	for _, e := range d.entries {
		if e.plat == plat && e.ref.HashAlgo == ref.HashAlgo {
			return fmt.Errorf("%s hash for %s has already been added", ref.HashAlgo, plat)
		}
	}
	d.entries = append(d.entries, clientDigestEntry{plat, ref})
	return nil
}
117618
func (c *Client) AddValueDescriptor(v contract.ValueDescriptor) (id string, err error) {
	conn := c.Pool.Get()
	defer conn.Close()

	if v.Id != "" {
		_, err = uuid.Parse(v.Id)
		if err != nil {
			return "", db.ErrInvalidObjectId
		}
	}
	return addValue(conn, v)
}
582524
func (m *clientConnMap) Add(dest string) error {
	// If the connection already exists, just exit early
	if _, ok := m.Get(dest); ok {
		return nil
	}

	conn, err := grpc.Dial(dest, m.options...)

	m.Lock()
	_, ok := m.conns[dest]
	if !ok && err == nil {
		m.conns[dest] = conn
	}
	m.Unlock()

	if ok && err == nil {
		_ = conn.Close()
	}

	return err
}
714332
func (b *Base) AddFuncIf(p Predicate, key string, f ValueConverter) Serializer {
	b.modifiers = append(b.modifiers, func(m jsonMap) jsonMap {
		if p(b.raw) {
			m[key] = f(b.raw)
		}
		return m
	})
	return b
}
298572
func NewClientWrapper(key string) client.Wrapper {
	return func(c client.Client) client.Client {
		return &shard{
			key:    key,
			Client: c,
		}
	}
}
1126977
func NewClient(
	cc *grpc.ClientConn,
	serviceName string,
	method string,
	enc EncodeRequestFunc,
	dec DecodeResponseFunc,
	grpcReply interface{},
	options ...ClientOption,
) *Client {
	c := &Client{
		client: cc,
		method: fmt.Sprintf("/%s/%s", serviceName, method),
		enc:    enc,
		dec:    dec,
		// We are using reflect.Indirect here to allow both reply structs and
		// pointers to these reply structs. New consumers of the client should
		// use structs directly, while existing consumers will not break if they
		// remain to use pointers to structs.
		grpcReply: reflect.TypeOf(
			reflect.Indirect(
				reflect.ValueOf(grpcReply),
			).Interface(),
		),
		before: []ClientRequestFunc{},
		after:  []ClientResponseFunc{},
	}
	for _, option := range options {
		option(c)
	}
	return c
}
861596
func (c Client) AddSubscription(s contract.Subscription) (string, error) {
	conn := c.Pool.Get()
	defer conn.Close()

	err := addSubscription(conn, &s)
	if err != nil {
		return "", err
	}

	return s.ID, nil
}
83720
func (f *Footer) AddRef() {
	f.m.Lock()
	f.refs++
	f.m.Unlock()
}
897068
func NewClient(dbURL string) (API, error) {
	// check if we should use default db
	if dbURL == "" {
		dbURL = defaultDbURL
	}

	parts := strings.Split(dbURL, "://")
	if len(parts) < 2 {
		log.Errorf("Invalid DB URL format %s", dbURL)
		return nil, errors.New("invalid DB URL")
	}
	clientName := parts[0]
	clientURL := parts[1]

	return InitClient(clientName, []string{"http://" + clientURL})
}
332604
func (s *llStore) addRef() *llStore {
	s.m.Lock()
	s.refs += 1
	s.m.Unlock()

	return s
}
109106
func (c *BitcoindConn) AddClient(client *BitcoindClient) {
	c.rescanClientsMtx.Lock()
	defer c.rescanClientsMtx.Unlock()

	c.rescanClients[client.id] = client
}
245534
func NewPostRef(client ClientInterface, post *MiniPost) *PostRef {
	return &PostRef{
		client:   client,
		MiniPost: *post,
	}
}
790582
func PutPropertyRef(disp *ole.IDispatch, name string, params ...interface{}) (result *ole.VARIANT, err error) {
	return disp.InvokeWithOptionalArgs(name, ole.DISPATCH_PROPERTYPUTREF, params)
}
582538
func UpdateRef(ref *Ref, to []byte, reason string) error {
	return UpdateRefIn("", ref, to, reason)
}
1310385
func (r *FileRef) AddRef() File {
	if r == nil {
		return nil
	}

	r.m.Lock()
	r.refs++
	file := r.file
	r.m.Unlock()

	return file
}
502095
func (p *PushEvent) GetRef() string {
	if p == nil || p.Ref == nil {
		return ""
	}
	return *p.Ref
}
1189239
func (s *Store) AddRef() {
	s.m.Lock()
	s.refs++
	s.m.Unlock()
}