dwp
dwp

Reputation: 958

How to update a extended participant in Hyperledger composer correctly?

Problem:

I have created an extended participant in .cto file in Hyperledger composer. It is like this.

participant User identified by nic{
o String nic 
o -----
o -----
o -----
o String verified
}

participant Seller extends User{
o ----
o ----
}

participant Buyer extends User{
o -----
o -----
}

But now I am pacing a problem. If I update some property of user should I update only user registry or should I have to update all three participant registries? Suppose that I am going to update the verified property of User. I look for a solution to solve this problem on the Internet but I was unable to find any good solution which will solve this problem. Thank you

Upvotes: 0

Views: 101

Answers (1)

Andre Defremont
Andre Defremont

Reputation: 83

Since the User participant is linked to Seller and Buyer someway, you don't need to update all others, i think that you just need to do something like:

   const participantRegistry = await getParticipantRegistry(you.org.net.User);
    let user = you.org.net.User#UserToUpdate
    user.verified = true;
      // Update the participant in the participant registry.
    await participantRegistry.update(user);

The same works for update a extended attribute:

     const participantRegistry = await getParticipantRegistry(you.org.net.Seller);
        let seller = you.org.net.Seller#UserToUpdate
        seller.atributteExtended = true;
          // Update the participant in the participant registry.
        await participantRegistry.update(seller);

Upvotes: 1

Related Questions