@@ -23,9 +23,6 @@ type ClientContext struct {
2323 provider clientProvider
2424}
2525
26- // ContextOption configures the client context created by the SDK.
27- type ContextOption func (opts * contextOptions ) error
28-
2926type contextOptions struct {
3027 orgID string
3128 config core.Config
@@ -41,7 +38,6 @@ type clientOptions struct {
4138type clientProvider func () (* clientContext , error )
4239
4340type clientContext struct {
44- opts * contextOptions
4541 identity contextApi.Identity
4642 providers providers
4743}
@@ -50,14 +46,6 @@ type providers interface {
5046 contextApi.Providers
5147}
5248
53- // WithOrg uses the configuration and users from the named organization.
54- func WithOrg (name string ) ContextOption {
55- return func (opts * contextOptions ) error {
56- opts .orgID = name
57- return nil
58- }
59- }
60-
6149// WithTargetFilter allows for filtering target peers.
6250func WithTargetFilter (targetFilter fab.TargetFilter ) ClientOption {
6351 return func (opts * clientOptions ) error {
@@ -66,35 +54,21 @@ func WithTargetFilter(targetFilter fab.TargetFilter) ClientOption {
6654 }
6755}
6856
69- // withConfig allows for overriding the configuration of the client.
70- // TODO: This should be removed once the depreacted functions are removed.
71- func withConfig (config core.Config ) ContextOption {
72- return func (opts * contextOptions ) error {
73- opts .config = config
74- return nil
75- }
76- }
77-
7857// NewClient allows creation of transactions using the supplied identity as the credential.
7958//Deprecated: use sdk.Context() or sdk.ChannelContext() instead
80- func (sdk * FabricSDK ) NewClient (identityOpt IdentityOption , opts ... ContextOption ) * ClientContext {
59+ func (sdk * FabricSDK ) NewClient (opts ... ContextOption ) * ClientContext {
8160 // delay execution of the following logic to avoid error return from this function.
8261 // this is done to allow a cleaner API - i.e., client, err := sdk.NewClient(args).<Desired Interface>(extra args)
8362 provider := func () (* clientContext , error ) {
84- o , err := newContextOptions (sdk .provider .Config (), opts )
85- if err != nil {
86- return nil , errors .WithMessage (err , "unable to retrieve configuration from SDK" )
87- }
8863
89- identity , err := sdk .newIdentity (identityOpt , WithOrgName ( o . orgID ) )
64+ identity , err := sdk .newIdentity (opts ... )
9065 if err != nil {
9166 return nil , errors .WithMessage (err , "unable to create client context" )
9267 }
9368
9469 cc := clientContext {
95- opts : o ,
9670 identity : identity ,
97- providers : & context.Client {Providers : & sdk .provider , Identity : identity },
71+ providers : & context.Client {Providers : sdk .provider , Identity : identity },
9872 }
9973 return & cc , nil
10074 }
@@ -104,32 +78,6 @@ func (sdk *FabricSDK) NewClient(identityOpt IdentityOption, opts ...ContextOptio
10478 return & client
10579}
10680
107- func newContextOptions (config core.Config , options []ContextOption ) (* contextOptions , error ) {
108- // Read default org name from configuration
109- client , err := config .Client ()
110- if err != nil {
111- return nil , errors .WithMessage (err , "unable to retrieve client from network config" )
112- }
113-
114- opts := contextOptions {
115- orgID : client .Organization ,
116- config : config ,
117- }
118-
119- for _ , option := range options {
120- err := option (& opts )
121- if err != nil {
122- return nil , errors .WithMessage (err , "error in option passed to client" )
123- }
124- }
125-
126- if opts .orgID == "" {
127- return nil , errors .New ("must provide default organisation name in configuration" )
128- }
129-
130- return & opts , nil
131- }
132-
13381func newClientOptions (options []ClientOption ) (* clientOptions , error ) {
13482 opts := clientOptions {}
13583
0 commit comments