in events/connection.js [29:56]
async function getClientForOrg (userorg, username) {
logger.info('============ START getClientForOrg for org %s and user %s', userorg, username);
let config = '../tmp/connection-profile/bank-connection-profile.yaml';
let clientConfig = '../tmp/connection-profile/' + userorg + '/client-' + userorg + '.yaml';
logger.info('##### getClient - Loading connection profiles from file: %s and %s', config, clientConfig);
// Load the connection profiles. First load the network settings, then load the client specific settings
let client = hfc.loadFromConfig(config);
client.loadFromConfig(clientConfig);
// Create the state store and the crypto store
await client.initCredentialStores();
// Try and obtain the user from persistence if the user has previously been
// registered and enrolled
if(username) {
let user = await client.getUserContext(username, true);
if(!user) {
throw new Error(util.format('##### getClient - User was not found :', username));
} else {
logger.info('##### getClient - User %s was found to be registered and enrolled', username);
}
}
logger.info('============ END getClientForOrg for org %s and user %s \n\n', userorg, username);
return client;
}