code: func (c *Client) calculateTargets(opts requestOptions) ([]fab.Peer, error) {
  
  	if opts.Targets != nil && opts.TargetFilter != nil {
  		return nil, errors.New("If targets are provided, filter cannot be provided")
  	}
  
  	targets := opts.Targets
  	targetFilter := opts.TargetFilter
  
  	var err error
  	if targets == nil {
  		// Retrieve targets from discovery
  		targets, err = c.discovery.GetPeers()
  		if err != nil {
  			return nil, err
  		}
  
  		if targetFilter == nil {
  			targetFilter = c.filter
  		}
  	}
  
  	if targetFilter != nil {
  		targets = filterTargets(targets, targetFilter)
  	}
  
  	if len(targets) == 0 {
  		return nil, errors.WithStack(status.New(status.ClientStatus, status.NoPeersFound.ToInt32(), "no targets available", nil))
  	}
  
  	if len(targets) < opts.MinTargets {
  		return nil, errors.Errorf("Error getting minimum number of targets. %d available, %d required", len(targets), opts.MinTargets)
  	}
  
  	// Calculate number of targets required
  	numOfTargets := opts.MaxTargets
  	if len(targets) < opts.MaxTargets {
  		numOfTargets = len(targets)
  	}
  
  	// Shuffle to randomize
  	shuffle(targets)
  
  	return targets[:numOfTargets], nil
  }
docs: // calculateTargets calculates targets based on targets and filter