code: func getRepositoryMountCandidates(
  	repoInfo reference.Named,
  	hmacKey []byte,
  	max int,
  	v2Metadata []metadata.V2Metadata,
  ) []metadata.V2Metadata {
  	candidates := []metadata.V2Metadata{}
  	for _, meta := range v2Metadata {
  		sourceRepo, err := reference.ParseNamed(meta.SourceRepository)
  		if err != nil || reference.Domain(repoInfo) != reference.Domain(sourceRepo) {
  			continue
  		}
  		// target repository is not a viable candidate
  		if meta.SourceRepository == repoInfo.Name() {
  			continue
  		}
  		candidates = append(candidates, meta)
  	}
  
  	sortV2MetadataByLikenessAndAge(repoInfo, hmacKey, candidates)
  	if max >= 0 && len(candidates) > max {
  		// select the youngest metadata
  		candidates = candidates[:max]
  	}
  
  	return candidates
  }
docs: // getRepositoryMountCandidates returns an array of v2 metadata items belonging to the given registry. The
  // array is sorted from youngest to oldest. If requireRegistryMatch is true, the resulting array will contain
  // only metadata entries having registry part of SourceRepository matching the part of repoInfo.