public String queryChaincode()

in src/main/java/com/lambdajavablockchain/service/ManagedBlockchainService.java [323:349]


    public String queryChaincode(HFClient hfClient, Channel channel, String chaincodeName, String functionName,
                                 String args) throws ManagedBlockchainServiceException, ProposalException, InvalidArgumentException {

        if (channel == null || hfClient == null) {
            log.error("Channel/Client not initialized. Run ManagedBlockchainService.initChannel() first");
            throw new ManagedBlockchainServiceException("Channel/Client not initialized!");
        }
        QueryByChaincodeRequest qpr = hfClient.newQueryProposalRequest();
        // Chaincode Version is omitted, it can be added if required
        ChaincodeID chaincodeID = ChaincodeID.newBuilder().setName(chaincodeName).build();
        qpr.setChaincodeID(chaincodeID);
        qpr.setFcn(functionName);
        String[] arguments = {args};
        qpr.setArgs(arguments);

        // Query the chaincode
        Collection<ProposalResponse> res = channel.queryByChaincode(qpr);

        String result = "";
        // Retrieve the query response
        for (ProposalResponse pres : res) {
            result = new String(pres.getChaincodeActionResponsePayload());
            log.info("Query result: " + result);
        }

        return result;
    }