In a hyperledger fabric network with multiple peers in an organization, Can I use Go SDK to query the chaincode through targetted peers from a particular organization?
I know I can query the chaincode using the channel package with the *channel.Client Query()
function, however, I need to query through each peer individually.
The way pass the targetted peers in Query
call on channel client is by using the channel.WithTargetEndpoints()
as a options parameter to the Query function.
An example to demonstrate this is:
req := channel.Request{
ChaincodeID: chaincodeID,
Fcn: "invoke",
Args: queryArg,
}
resp, err := client.Query(req, channel.WithTargetEndpoints("peer0.org0.example.com"), channel.WithRetry(retry.DefaultChannelOpts))