1. Get configuration from a configuration file using config.FromFile(path_to_config_file), this returns a ConfigProvider type.
2. Use ConfigProvider function and fabsdk.Option to create a sdk.
sdk := fabsdk.New(configOpt, sdkOpts...)
3. Use sdk.Context to create a client context.
clientContext := sdk.Context(fabsdk.WithUser(orgAdmin),
fabsdk.WithOrg(ordererOrgName))
resMgmtClient, err := resmgmt.New(clientContext)
mspClient, err := mspclient.New(sdk.Context(),
mspclient.WithOrg(orgName))
adminIdentity, err := mspClient.GetSigningIdentity(orgAdmin)
req := resmgmt.SaveChannelRequest{ChannelID: channelID,
ChannelConfigPath: integration.GetChannelConfigPath(channelID + ".tx"),
SigningIdentities: []msp.SigningIdentity{adminIdentity}}
txID, err := resMgmtClient.SaveChannel(req,
resmgmt.WithRetry(retry.DefaultResMgmtOpts),
resmgmt.WithOrdererEndpoint("orderer.example.com"))
require.Nil(t, err, "error should be nil")
require.NotEmpty(t, txID, "transaction ID should be populated")
No comments:
Post a Comment