code: func (rc *Client) calculateTargets(targets []fab.Peer, filter fab.TargetFilter) ([]fab.Peer, error) {
  
  	targetFilter := filter
  
  	if len(targets) == 0 {
  		// Retrieve targets from discovery
  		localCtx, err := rc.localCtxProvider()
  		if err != nil {
  			return nil, errors.WithMessage(err, "failed to create local context")
  		}
  		targets, err = localCtx.LocalDiscoveryService().GetPeers()
  		if err != nil {
  			return nil, err
  		}
  
  		if filter == nil {
  			targetFilter = rc.filter
  		}
  	}
  
  	if targetFilter != nil {
  		targets = filterTargets(targets, targetFilter)
  	}
  
  	return targets, nil
  }
docs: // calculateTargets calculates targets based on targets and filter