Dynamically assign endorsing or chaincode query role to channel peers in the Fabric Node SDK #fabric-sdk-node #fabric #hyperledger-fabric
I am using the following Fabric Versions:
1. Fabric binaries: 1.4.4.
2. Fabric Node SDK version: 1.4.9 (fabric-network, fabric-client, fabric-ca-client).
3. Node.js version: v8.10.0
I wish to perform "query" operation on the channel using Fabric Node SDK, preferably using the "fabric-network" components. I have only 1 peer as the endorsing peer (one that has chaincode installed on it) out of 3 peers in total on the channel for that peer organization. NOTE: I do not have the roles assigned to these peers in the "connection-profile" explicitly and I am using "discovery" to be enabled on the channel.
I assumed that the SDK function "setEndorsingPeers" from the "transaction.js" module will allow me to dynamically assign role to the peers based upon user input. But when I deep-dived into the Fabric Node SDK code, I saw that, the "evaluate" function in the "transaction.js" calls the default query handler, which sends the proposal randomly to one of the peers using "MSPID_SCOPE_SINGLE" phenomenon.
But because the discovery is enabled, the request may go to dynamically a committing peer, and returns failure. I know one possible solution is to use my custom query handler. But, I wish to identify, if dynamically I can assign endorsing or chaincode query role to channel peers in the Fabric Node SDK (v1.4.9)?