// NewChannelStream returns a new channel stream instance with blocked channels, so ensure to fullfill the contract of removing the data you need only
327310
func NewChannelStream() *ChannelStream {
	cs := ChannelStream{
		Data:  make(chan interface{}),
		Error: make(chan error),
	}
	return &cs
}
534442
func NewRequestStream(streams ...RequestStream) RequestStream {
	switch len(streams) {
	case 0:
		return nil
	case 1:
		return streams[0]
	default:
	}

	linkRequest(streams[0], streams[1])

	return struct {
		RequestConsumer
		RequestProducer
	}{
		streams[0],
		NewRequestStream(streams[1:]...),
	}
}
1191511
func NewMomForStream(priceStream gotrade.DOHLCVStreamSubscriber, timePeriod int, selectData gotrade.DOHLCVDataSelectionFunc) (indicator *Mom, err error) {
	newMom, err := NewMom(timePeriod, selectData)
	priceStream.AddTickSubscription(newMom)
	return newMom, err
}
387215
func NewChannelConfig(channelGroup *cb.ConfigGroup) (*ChannelConfig, error) {
	cc := &ChannelConfig{
		protos: &ChannelProtos{},
	}

	if err := DeserializeProtoValuesFromGroup(channelGroup, cc.protos); err != nil {
		return nil, errors.Wrap(err, "failed to deserialize values")
	}

	if err := cc.Validate(); err != nil {
		return nil, err
	}

	capabilities := cc.Capabilities()
	mspConfigHandler := NewMSPConfigHandler(capabilities.MSPVersion())

	var err error
	for groupName, group := range channelGroup.Groups {
		switch groupName {
		case ApplicationGroupKey:
			cc.appConfig, err = NewApplicationConfig(group, mspConfigHandler)
		case OrdererGroupKey:
			cc.ordererConfig, err = NewOrdererConfig(group, mspConfigHandler)
		case ConsortiumsGroupKey:
			cc.consortiumsConfig, err = NewConsortiumsConfig(group, mspConfigHandler)
		default:
			return nil, fmt.Errorf("Disallowed channel group: %s", group)
		}
		if err != nil {
			return nil, errors.Wrapf(err, "could not create channel %s sub-group config", groupName)
		}
	}

	if cc.mspManager, err = mspConfigHandler.CreateMSPManager(); err != nil {
		return nil, err
	}

	return cc, nil
}
35035
func NewAdlForStream(priceStream gotrade.DOHLCVStreamSubscriber) (indicator *Adl, err error) {
	ind, err := NewAdl()
	priceStream.AddTickSubscription(ind)
	return ind, err
}
923037
func NewLlvForStream(priceStream gotrade.DOHLCVStreamSubscriber, timePeriod int, selectData gotrade.DOHLCVDataSelectionFunc) (indicator *Llv, err error) {
	ind, err := NewLlv(timePeriod, selectData)
	priceStream.AddTickSubscription(ind)
	return ind, err
}
608090
func New(channelProvider context.ChannelProvider, opts ...ClientOption) (*Client, error) {

	channelContext, err := channelProvider()
	if err != nil {
		return nil, errors.WithMessage(err, "failed to create channel context")
	}

	eventClient := Client{}

	for _, param := range opts {
		err1 := param(&eventClient)
		if err1 != nil {
			return nil, errors.WithMessage(err, "option failed")
		}
	}

	if channelContext.ChannelService() == nil {
		return nil, errors.New("channel service not initialized")
	}

	var es fab.EventService
	if eventClient.permitBlockEvents {
		var opts []options.Opt
		opts = append(opts, client.WithBlockEvents())
		if eventClient.seekType != "" {
			opts = append(opts, deliverclient.WithSeekType(eventClient.seekType))
			if eventClient.seekType == seek.FromBlock {
				opts = append(opts, deliverclient.WithBlockNum(eventClient.fromBlock))
			}
		}
		es, err = channelContext.ChannelService().EventService(opts...)
	} else {
		es, err = channelContext.ChannelService().EventService()
	}

	if err != nil {
		return nil, errors.WithMessage(err, "event service creation failed")
	}

	eventClient.eventService = es

	return &eventClient, nil
}
335276
func NewWillRForStream(priceStream gotrade.DOHLCVStreamSubscriber, timePeriod int) (indicator *WillR, err error) {
	ind, err := NewWillR(timePeriod)
	priceStream.AddTickSubscription(ind)
	return ind, err
}
1129789
func NewDxForStream(priceStream gotrade.DOHLCVStreamSubscriber, timePeriod int) (indicator *Dx, err error) {
	ind, err := NewDx(timePeriod)
	priceStream.AddTickSubscription(ind)
	return ind, err
}
987111
func (lc *Lifecycle) NewChannelSubscription(channel string, queryCreator QueryCreator) (*Subscription, error) {
	sub := &Subscription{
		lc:           lc,
		channel:      channel,
		queryCreator: queryCreator,
	}
	// Initialize metadata for the channel.
	// This loads metadata about all installed chaincodes
	if err := lc.initMetadataForChannel(channel, queryCreator); err != nil {
		return nil, errors.WithStack(err)
	}
	lc.fireChangeListeners(channel)
	return sub, nil
}
1290266
func NewChannelPool(poolConfig *Config) (Pool, error) {
	if poolConfig.InitialCap < 0 || poolConfig.MaxCap <= 0 || poolConfig.InitialCap > poolConfig.MaxCap {
		return nil, errors.New("invalid capacity settings")
	}
	if poolConfig.Factory == nil {
		return nil, errors.New("invalid factory func settings")
	}
	if poolConfig.Close == nil {
		return nil, errors.New("invalid close func settings")
	}

	c := &channelPool{
		conns:       make(chan *idleConn, poolConfig.MaxCap),
		factory:     poolConfig.Factory,
		close:       poolConfig.Close,
		idleTimeout: poolConfig.IdleTimeout,
	}

	if poolConfig.Ping != nil {
		c.ping = poolConfig.Ping
	}

	for i := 0; i < poolConfig.InitialCap; i++ {
		conn, err := c.factory()
		if err != nil {
			c.Release()
			return nil, fmt.Errorf("factory is not able to fill the pool: %s", err)
		}
		c.conns <- &idleConn{conn: conn, t: time.Now()}
	}

	return c, nil
}
1346706
func (ms *MemoryStore) CreateChannel(channel string) (*Channel, error) {
	ms.Lock()
	defer ms.Unlock()

	// Verify that it does not already exist or that we did not hit the limits
	if err := ms.canAddChannel(channel); err != nil {
		return nil, err
	}

	channelLimits := ms.genericStore.getChannelLimits(channel)

	msgStore := &MemoryMsgStore{msgs: make(map[uint64]*pb.MsgProto, 64)}
	msgStore.init(channel, ms.log, &channelLimits.MsgStoreLimits)

	subStore := &MemorySubStore{}
	subStore.init(ms.log, &channelLimits.SubStoreLimits)

	c := &Channel{
		Subs: subStore,
		Msgs: msgStore,
	}
	ms.channels[channel] = c

	return c, nil
}
918388
func NewMockStream(ctx context.Context, recvSize, sentSize int, recvTimeout, sentTimeout time.Duration) *MockStream {
	return &MockStream{
		ctx:         ctx,
		recv:        make(chan *envoy_api_v2.DiscoveryRequest, recvSize),
		sent:        make(chan *envoy_api_v2.DiscoveryResponse, sentSize),
		recvTimeout: recvTimeout,
		sentTimeout: sentTimeout,
	}
}
449240
func New(chanDB *channeldb.DB) *ChannelNotifier {
	return &ChannelNotifier{
		ntfnServer: subscribe.NewServer(),
		chanDB:     chanDB,
	}
}
28169
func NewMockChannel(channelID string) (*Channel, error) {

	ctx := &mockClientContext{
		Providers:       NewMockProviderContext(),
		SigningIdentity: mspmocks.NewMockSigningIdentity("user", "Org1MSP"),
	}

	// Set up mock channel service
	chProvider, err := NewMockChannelProvider(ctx)
	if err != nil {
		return nil, errors.WithMessage(err, "new mock channel provider failed")
	}
	channelService, err := chProvider.ChannelService(ctx, channelID)
	if err != nil {
		return nil, errors.WithMessage(err, "failed to create mock channel service")
	}

	peer := NewMockPeer("Peer1", "example.com")

	channelService.(*MockChannelService).SetDiscovery(NewMockDiscoveryService(nil, peer))
	channelService.(*MockChannelService).SetSelection(NewMockSelectionService(nil, peer))

	channel := &Channel{
		Client:         ctx,
		channelService: channelService,
		channelID:      channelID,
	}

	return channel, nil
}
441264
func NewChannelArbitrator(cfg ChannelArbitratorConfig,
	startingHTLCs []channeldb.HTLC, log ArbitratorLog) *ChannelArbitrator {

	return &ChannelArbitrator{
		log:              log,
		signalUpdates:    make(chan *signalUpdateMsg),
		htlcUpdates:      make(<-chan []channeldb.HTLC),
		resolutionSignal: make(chan struct{}),
		forceCloseReqs:   make(chan *forceCloseReq),
		activeHTLCs:      newHtlcSet(startingHTLCs),
		cfg:              cfg,
		quit:             make(chan struct{}),
	}
}
1361051
func newChannelCache(n int) *channelCache {
	return &channelCache{
		n:        n,
		channels: make(map[uint64]ChannelEdge),
	}
}