Search code examples
hyperledger-fabricprivateservice-discoverydata-collectionhyperledger-fabric-sdk-java

Hyperledger Fabric: Service discovery for private data collection


In Hyperledger Fabric, does service discovery support finding query peers for private data collection (PDC).

In a channel consisting of 2 orgs (org1 and org2), if I create a PDC for org1 only, only the peers in org1 hold the private data. If in PDC collection profile I specify memberReadOnly=false, it allows org2 users to query org1 peer to read the private data. But this requires the support of service discovery in peers and Fabric Java SDK.

The objective we'd like to accomplish is in client side as org2 user, via Java SDK, when calling chaincode to read the private data, the SDK will automatically connect to org1 peer.

Is this currently supported.


Solution

  • Yeah, discovery supports private data.

    If you take a look at the discovery CLI which implements the client side API (apart from SDKs) you will see that the endorsement query has a --collection flag.

    For example the following flags --chaincode=cc1 --chaincode=cc2 --collection=cc2:col1 to the discover endorsers command mean you want to ask about a transaction which writes to chaincodes cc1 and cc2 and also while invoking cc2 you are writing/reading to/from collection col.

    In Fabric 2.1 we added another flag --noPrivateReads which hints discovery that you only want to write to the collection but not read from it.