// resolveOnce implements resolver.
553134
func (r *Resolver) resolveOnce(domain string) (p string, err error) {
	r.setDefaults()

	if !isd.IsDomain(domain) {
		return "", ErrInvalidDomain
	}

	txt, err := r.lookupTXT(domain)
	if err != nil {
		return "", err
	}

	err = ErrResolveFailed
	for _, t := range txt {
		p, err = ParseTXT(t)
		if err == nil {
			return p, nil
		}
	}

	return "", err
}
41475
func ResolveName(node ast.Node, info infoschema.InfoSchema, ctx context.Context) error {
	defaultSchema := ctx.GetSessionVars().CurrentDB
	resolver := nameResolver{Info: info, Ctx: ctx, DefaultSchema: model.NewCIStr(defaultSchema)}
	node.Accept(&resolver)
	return errors.Trace(resolver.Err)
}
438294
func (m *MultiResolver) Resolve(addr string) (h common.Hash, err error) {
	rs, err := m.getResolveValidator(addr)
	if err != nil {
		return h, err
	}
	for _, r := range rs {
		h, err = r.Resolve(addr)
		if err == nil {
			return
		}
	}
	return
}
311591
func (c *Repair) RunOnce() error {
	return retry.RetryOnConflict(retry.DefaultBackoff, c.runOnce)
}
153110
func NewResolver(cmd *cobra.Command, c api.ControlClient) *Resolver {
	return &Resolver{
		cmd:   cmd,
		c:     c,
		ctx:   Context(cmd),
		cache: make(map[string]string),
	}
}
941041
func (s *AcknowledgeJobInput) SetNonce(v string) *AcknowledgeJobInput {
	s.Nonce = &v
	return s
}
1179397
func (it *Resolver) resolve(ctx context.Context) error {
	values, err := graph.RefsOf(ctx, it.qs, it.order)
	if err != nil {
		return err
	}
	for index, value := range values {
		node := it.order[index]
		it.values[node] = value
		it.nodes[value.Key()] = node
	}
	it.cached = true
	return nil
}
1092630
func (rc *retryObjectReader) readOnce(p []byte) (n int, err error) {
	// Set up the wrapped reader if it's not already around.
	if rc.wrapped == nil {
		err = rc.setUpWrapped()
		if err != nil {
			return
		}
	}

	// Attempt to read from it.
	n, err = rc.wrapped.Read(p)
	if err != nil {
		rc.wrapped.Close()
		rc.wrapped = nil
		return
	}

	return
}
1315994
func (r *resolver) Resolve(it *config.Config) error {
	return r.resolveItem(r.single, it.Content, it.FormatSpec.Formatter)
}
763630
func (r FirstMatchResolver) Resolve(value string) (*ComponentMatch, error) {
	matches, err := r.Searcher.Search(true, value)
	if len(matches) == 0 {
		return nil, ErrNoMatch{Value: value, Errs: err, Type: r.Searcher.Type()}
	}
	return matches[0], errors.NewAggregate(err)
}
379572
func (n *Node) ResolvePath(x string) string {
	return n.config.ResolvePath(x)
}
1011910
func (r *referenceResolver) resolveReference(ref *ShapeRef) {
	if ref.ShapeName == "" {
		return
	}

	shape, ok := r.API.Shapes[ref.ShapeName]
	if !ok {
		panic(fmt.Sprintf("unable resolve reference, %s", ref.ShapeName))
	}

	if ref.JSONValue {
		ref.ShapeName = "JSONValue"
		if _, ok := r.API.Shapes[ref.ShapeName]; !ok {
			r.API.Shapes[ref.ShapeName] = &Shape{
				API:       r.API,
				ShapeName: "JSONValue",
				Type:      "jsonvalue",
				ValueRef: ShapeRef{
					JSONValue: true,
				},
			}
		}
	}

	ref.API = r.API   // resolve reference back to API
	ref.Shape = shape // resolve shape reference

	if r.visited[ref] {
		return
	}
	r.visited[ref] = true

	shape.refs = append(shape.refs, ref) // register the ref

	// resolve shape's references, if it has any
	r.resolveShape(shape)
}
884556
func (cli *Client) SendOnce(remote string, code ...string) (err error) {
	_, err = cli.send("SEND_ONCE", remote, code...)
	return
}
724190
func (api *CoreAPI) ResolvePath(ctx context.Context, p path.Path) (path.Resolved, error) {
	if _, ok := p.(path.Resolved); ok {
		return p.(path.Resolved), nil
	}
	if err := p.IsValid(); err != nil {
		return nil, err
	}

	ipath := ipfspath.Path(p.String())
	ipath, err := resolve.ResolveIPNS(ctx, api.namesys, ipath)
	if err == resolve.ErrNoNamesys {
		return nil, coreiface.ErrOffline
	} else if err != nil {
		return nil, err
	}

	var resolveOnce resolver.ResolveOnce

	switch ipath.Segments()[0] {
	case "ipfs":
		resolveOnce = uio.ResolveUnixfsOnce
	case "ipld":
		resolveOnce = resolver.ResolveSingle
	default:
		return nil, fmt.Errorf("unsupported path namespace: %s", p.Namespace())
	}

	r := &resolver.Resolver{
		DAG:         api.dag,
		ResolveOnce: resolveOnce,
	}

	node, rest, err := r.ResolveToLastNode(ctx, ipath)
	if err != nil {
		return nil, err
	}

	root, err := cid.Parse(ipath.Segments()[1])
	if err != nil {
		return nil, err
	}

	return path.NewResolvedPath(ipath, node, root, gopath.Join(rest...)), nil
}
655602
func (r *Resolver) ResolveN(domain string, depth int) (link string, err error) {
	tail := ""
	for i := 0; i < depth; i++ {
		link, err = r.resolveOnce(domain)
		if err != nil {
			return "", err
		}

		// if does not have /dns/ as a prefix, done.
		if !strings.HasPrefix(link, "/dns/") {
			return link + tail, nil // done
		}

		// keep resolving
		d, rest, err := ParseLinkDomain(link)
		if err != nil {
			return "", err
		}

		domain = d
		tail = rest + tail
	}
	return "/dns/" + domain + tail, ErrResolveLimit
}
1091112
func (ns *mpns) resolveOnceAsync(ctx context.Context, name string, options opts.ResolveOpts) <-chan onceResult {
	out := make(chan onceResult, 1)

	if !strings.HasPrefix(name, ipnsPrefix) {
		name = ipnsPrefix + name
	}
	segments := strings.SplitN(name, "/", 4)
	if len(segments) < 3 || segments[0] != "" {
		log.Debugf("invalid name syntax for %s", name)
		out <- onceResult{err: ErrResolveFailed}
		close(out)
		return out
	}

	key := segments[2]

	if p, ok := ns.cacheGet(key); ok {
		if len(segments) > 3 {
			var err error
			p, err = path.FromSegments("", strings.TrimRight(p.String(), "/"), segments[3])
			if err != nil {
				emitOnceResult(ctx, out, onceResult{value: p, err: err})
			}
		}

		out <- onceResult{value: p}
		close(out)
		return out
	}

	// Resolver selection:
	// 1. if it is a multihash resolve through "ipns".
	// 2. if it is a domain name, resolve through "dns"
	// 3. otherwise resolve through the "proquint" resolver

	var res resolver
	if _, err := mh.FromB58String(key); err == nil {
		res = ns.ipnsResolver
	} else if isd.IsDomain(key) {
		res = ns.dnsResolver
	} else {
		res = ns.proquintResolver
	}

	resCh := res.resolveOnceAsync(ctx, key, options)
	var best onceResult
	go func() {
		defer close(out)
		for {
			select {
			case res, ok := <-resCh:
				if !ok {
					if best != (onceResult{}) {
						ns.cacheSet(key, best.value, best.ttl)
					}
					return
				}
				if res.err == nil {
					best = res
				}
				p := res.value

				// Attach rest of the path
				if len(segments) > 3 {
					var err error
					p, err = path.FromSegments("", strings.TrimRight(p.String(), "/"), segments[3])
					if err != nil {
						emitOnceResult(ctx, out, onceResult{value: p, ttl: res.ttl, err: err})
					}
				}

				emitOnceResult(ctx, out, onceResult{value: p, ttl: res.ttl, err: res.err})
			case <-ctx.Done():
				return
			}
		}
	}()

	return out
}
787790
func GetNonce(prop *peer.Proposal) ([]byte, error) {
	if prop == nil {
		return nil, errors.New("proposal is nil")
	}

	// get back the header
	hdr, err := GetHeader(prop.Header)
	if err != nil {
		return nil, err
	}

	chdr, err := UnmarshalChannelHeader(hdr.ChannelHeader)
	if err != nil {
		return nil, err
	}

	if err = validateChannelHeaderType(chdr, []common.HeaderType{common.HeaderType_ENDORSER_TRANSACTION, common.HeaderType_CONFIG}); err != nil {
		return nil, errors.WithMessage(err, "invalid proposal")
	}

	shdr, err := GetSignatureHeader(hdr.SignatureHeader)
	if err != nil {
		return nil, err
	}

	if hdr.SignatureHeader == nil {
		return nil, errors.New("invalid signature header. cannot be nil")
	}

	return shdr.Nonce, nil
}