Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to enroll user in new org added to balance transfer sample

I am following Balance transfer from Hyperledger Fabric samples from this link. I have modified it a bit, now I have 3 Orgs with 1 Peer each. All goes fine till I enroll users to Org1 and Org2 but, when I try to enroll a user to my 3rd Org I get following error

Failed to get registered user: xyz with error: Error: fabric-ca request register failed with errors [[{"code":63,"message":"Failed to get Affiliation: sql: no rows in result set"}]]

My Binaries of Hyperledger Fabric are from version 1.1.0 Alfa

like image 620
Atif Avatar asked Feb 17 '18 00:02

Atif


1 Answers

This may be useless (and very late), but I'd like to add to Gari's answer. You can also add affiliations using the node client SDK's AffiliationService class.
To do this in the balance transfer code, modify helper.js with:

let adminUserObj = await client.setUserContext({
                        username: admins[0].username, 
                        password: admins[0].secret});

let caClient = client.getCertificateAuthority();
let affiliationService = caClient.newAffiliationService();

let registeredAffiliations = await affiliationService.getAll(adminUserObj);
if(!registeredAffiliations.result.affiliations.some(
    x => x.name == userOrg.toLowerCase())){
        let affiliation = 'org3.department1'; 
        await affiliationService.create({
                        name: affiliation, 
                        force: true}, adminUserObj);
}

Note:
The above code only adds the affiliations (which I think is the only thing missing in your case). To successfully enroll a user for Org3, you'll also have specify org3 in artifacts/channel/cryptogen.yaml, artifacts/channel/configtx.yaml, artifacts/docker-compose.yaml, artifacts/network-config.yaml and config.json. And create an org3.yaml file.

I built a chaincode sample app with the balance transfer sample as a base which has 3 orgs. You can take a look at it to see the necessary changes.

like image 122
Krishna Moniz Avatar answered Oct 08 '22 23:10

Krishna Moniz