Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: expose ChannelProvider from the gateway #244

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions pkg/gateway/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,13 +259,21 @@ func WithBlockNum(from uint64) Option {
// Returns:
// A Network object representing the channel
func (gw *Gateway) GetNetwork(name string) (*Network, error) {
var channelProvider context.ChannelProvider
channelProvider := gw.GetChannelProvider(name)
return newNetwork(gw, channelProvider)
}

// GetChannelProvider returns a ChannelProvider function.
// Parameters:
// name is the name of the network channel
//
// Returns:
// A function returning a Channel client context
func (gw *Gateway) GetChannelProvider(name string) context.ChannelProvider {
if gw.options.Identity != nil {
channelProvider = gw.sdk.ChannelContext(name, fabsdk.WithIdentity(gw.options.Identity), fabsdk.WithOrg(gw.org))
} else {
channelProvider = gw.sdk.ChannelContext(name, fabsdk.WithUser(gw.options.User), fabsdk.WithOrg(gw.org))
return gw.sdk.ChannelContext(name, fabsdk.WithIdentity(gw.options.Identity), fabsdk.WithOrg(gw.org))
}
return newNetwork(gw, channelProvider)
return gw.sdk.ChannelContext(name, fabsdk.WithUser(gw.options.User), fabsdk.WithOrg(gw.org))
}

// Close the gateway connection and all associated resources, including removing listeners attached to networks and
Expand Down