func WithPeers(peers []fab.Peer) Option {
	return func(opts *Opts) error {
		opts.Targets = peers
		return nil
	}
}
WithPeers encapsulates peers to Option
package chconfig
import (
	"github.com/golang/protobuf/proto"
	fab "github.com/hyperledger/fabric-sdk-go/api/apifabclient"
	"github.com/hyperledger/fabric-sdk-go/pkg/fabric-client/channel"
	"github.com/hyperledger/fabric-sdk-go/pkg/fabric-client/peer"
	"github.com/hyperledger/fabric-sdk-go/pkg/logging"
	"github.com/hyperledger/fabric-sdk-go/third_party/github.com/hyperledger/fabric/protos/common"
	msp "github.com/hyperledger/fabric-sdk-go/third_party/github.com/hyperledger/fabric/protos/msp"
	ab "github.com/hyperledger/fabric-sdk-go/third_party/github.com/hyperledger/fabric/protos/orderer"
	pb "github.com/hyperledger/fabric-sdk-go/third_party/github.com/hyperledger/fabric/protos/peer"
	"github.com/pkg/errors"
	channelConfig "github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric/common/channelconfig"
	imsp "github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric/msp"
)
var logger = logging.NewLogger("fabric_sdk_go")
const (
	defaultMinResponses = 1
)
type Opts struct {
	Orderer      string      
	Targets      []fab.Peer  
	MinResponses int         
}
type Option func(opts *Opts) error
type Context struct {
	fab.ProviderContext
	fab.IdentityContext
}
type ChannelConfig struct {
	channelID string
	ctx       fab.Context
	opts      Opts
}
type ChannelCfg struct {
	name        string
	msps        []*msp.MSPConfig
	anchorPeers []*fab.OrgAnchorPeer
	orderers    []string
	versions    *fab.Versions
}
func NewChannelCfg(name string) fab.ChannelCfg {
	return &ChannelCfg{name: name}
}
func (cfg *ChannelCfg) Name() string {
	return cfg.name
}
func (cfg *ChannelCfg) Msps() []*msp.MSPConfig {
	return cfg.msps
}
func (cfg *ChannelCfg) AnchorPeers() []*fab.OrgAnchorPeer {
	return cfg.anchorPeers
}
func (cfg *ChannelCfg) Orderers() []string {
	return cfg.orderers
}
func (cfg *ChannelCfg) Versions() *fab.Versions {
	return cfg.versions
}
func New(ctx fab.Context, channelID string, options ...Option) (*ChannelConfig, error) {
	opts, err := prepareOpts(options...)
	if err != nil {
		return nil, err
	}
	return &ChannelConfig{channelID: channelID, ctx: ctx, opts: opts}, nil
}
func (c *ChannelConfig) Query() (fab.ChannelCfg, error) {
	if c.opts.Orderer != "" {
		return c.queryOrderer()
	}
	return c.queryPeers()
}
func (c *ChannelConfig) queryPeers() (*ChannelCfg, error) {
	ch, err := channel.New(c.ctx, &ChannelCfg{name: c.channelID})
	if err != nil {
		return nil, errors.WithMessage(err, "NewChannel failed")
	}
	targets := c.opts.Targets
	if targets == nil {
		chPeers, err := c.ctx.Config().ChannelPeers(c.channelID)
		if err != nil {
			return nil, errors.WithMessage(err, "read configuration for channel peers failed")
		}
		targets = []fab.Peer{}
		for _, p := range chPeers {
			newPeer, err := peer.New(c.ctx.Config(), peer.FromPeerConfig(&p.NetworkPeer))
			if err != nil || newPeer == nil {
				return nil, errors.WithMessage(err, "NewPeer failed")
			}
			targets = append(targets, newPeer)
		}
	}
	minEndorsers := c.opts.MinResponses
	if minEndorsers == 0 {
		minEndorsers = defaultMinResponses
	}
	configEnvelope, err := ch.QueryConfigBlock(targets, minEndorsers)
	if err != nil {
		return nil, errors.WithMessage(err, "QueryBlockConfig failed")
	}
	return extractConfig(c.channelID, configEnvelope)
}
func (c *ChannelConfig) queryOrderer() (*ChannelCfg, error) {
	ch, err := channel.New(c.ctx, &ChannelCfg{name: c.channelID, orderers: []string{c.opts.Orderer}})
	if err != nil {
		return nil, errors.WithMessage(err, "NewChannel failed")
	}
	configEnvelope, err := ch.ChannelConfig()
	if err != nil {
		return nil, errors.WithMessage(err, "ChannelConfig() failed")
	}
	return extractConfig(c.channelID, configEnvelope)
}