Java Code Examples for org.hyperledger.fabric.sdk.InstantiateProposalRequest#setArgs()
The following examples show how to use
org.hyperledger.fabric.sdk.InstantiateProposalRequest#setArgs() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FabricSDKWrapper.java From WeEvent with Apache License 2.0 | 6 votes |
public static Collection<ProposalResponse> instantiateProposal(HFClient client, Channel channel, ChaincodeID chaincodeID, TransactionRequest.Type chaincodeLang, Long proposalTimeout) throws InvalidArgumentException, ProposalException { InstantiateProposalRequest instantiateProposalRequest = client.newInstantiationProposalRequest(); instantiateProposalRequest.setProposalWaitTime(proposalTimeout);//time in milliseconds instantiateProposalRequest.setChaincodeID(chaincodeID); instantiateProposalRequest.setChaincodeLanguage(chaincodeLang); instantiateProposalRequest.setFcn("init"); instantiateProposalRequest.setArgs(new String[]{}); // I do not know the purpose of transient map works for. Map<String, byte[]> transientMap = new HashMap<>(); transientMap.put("HyperLedgerFabric", "InstantiateProposalRequest:JavaSDK".getBytes(UTF_8)); transientMap.put("method", "InstantiateProposalRequest".getBytes(UTF_8)); instantiateProposalRequest.setTransientMap(transientMap); return channel.sendInstantiationProposal(instantiateProposalRequest, channel.getPeers()); }
Example 2
Source File: QueryBlock.java From fabric-jdbc-connector with Apache License 2.0 | 6 votes |
private InstantiateProposalRequest getInstantiateProposalRequest(String chaincodeName, String chainCodeVersion, String chainCodePath, String chaincodeFunction, String[] chaincodeArgs, Endorsers endorsers) throws InvalidArgumentException { client.setUserContext(userOrg.getPeerAdmin()); ChaincodeID chaincodeID = ChaincodeID.newBuilder().setName(chaincodeName).setVersion(chainCodeVersion) .setPath(chainCodePath).build(); InstantiateProposalRequest instantiateProposalRequest = client.newInstantiationProposalRequest(); instantiateProposalRequest.setProposalWaitTime(conf.getProposalWaitTime()); instantiateProposalRequest.setChaincodeID(chaincodeID); instantiateProposalRequest.setFcn(chaincodeFunction); instantiateProposalRequest.setArgs(chaincodeArgs); if(endorsers != null) { ChaincodeEndorsementPolicy policy = getChaincodeEndorsementPolicy(endorsers); instantiateProposalRequest.setChaincodeEndorsementPolicy(policy); } return instantiateProposalRequest; }
Example 3
Source File: ChannelClient.java From blockchain-application-using-fabric-java-sdk with Apache License 2.0 | 4 votes |
/** * * Instantiate chaincode. * * @param chaincodeName * @param version * @param chaincodePath * @param language * @param functionName * @param functionArgs * @param policyPath * @return * @throws InvalidArgumentException * @throws ProposalException * @throws ChaincodeEndorsementPolicyParseException * @throws IOException */ public Collection<ProposalResponse> instantiateChainCode(String chaincodeName, String version, String chaincodePath, String language, String functionName, String[] functionArgs, String policyPath) throws InvalidArgumentException, ProposalException, ChaincodeEndorsementPolicyParseException, IOException { Logger.getLogger(ChannelClient.class.getName()).log(Level.INFO, "Instantiate proposal request " + chaincodeName + " on channel " + channel.getName() + " with Fabric client " + fabClient.getInstance().getUserContext().getMspId() + " " + fabClient.getInstance().getUserContext().getName()); InstantiateProposalRequest instantiateProposalRequest = fabClient.getInstance() .newInstantiationProposalRequest(); instantiateProposalRequest.setProposalWaitTime(180000); ChaincodeID.Builder chaincodeIDBuilder = ChaincodeID.newBuilder().setName(chaincodeName).setVersion(version) .setPath(chaincodePath); ChaincodeID ccid = chaincodeIDBuilder.build(); Logger.getLogger(ChannelClient.class.getName()).log(Level.INFO, "Instantiating Chaincode ID " + chaincodeName + " on channel " + channel.getName()); instantiateProposalRequest.setChaincodeID(ccid); if (language.equals(Type.GO_LANG.toString())) instantiateProposalRequest.setChaincodeLanguage(Type.GO_LANG); else instantiateProposalRequest.setChaincodeLanguage(Type.JAVA); instantiateProposalRequest.setFcn(functionName); instantiateProposalRequest.setArgs(functionArgs); Map<String, byte[]> tm = new HashMap<>(); tm.put("HyperLedgerFabric", "InstantiateProposalRequest:JavaSDK".getBytes(UTF_8)); tm.put("method", "InstantiateProposalRequest".getBytes(UTF_8)); instantiateProposalRequest.setTransientMap(tm); if (policyPath != null) { ChaincodeEndorsementPolicy chaincodeEndorsementPolicy = new ChaincodeEndorsementPolicy(); chaincodeEndorsementPolicy.fromYamlFile(new File(policyPath)); instantiateProposalRequest.setChaincodeEndorsementPolicy(chaincodeEndorsementPolicy); } Collection<ProposalResponse> responses = channel.sendInstantiationProposal(instantiateProposalRequest); CompletableFuture<TransactionEvent> cf = channel.sendTransaction(responses); Logger.getLogger(ChannelClient.class.getName()).log(Level.INFO, "Chaincode " + chaincodeName + " on channel " + channel.getName() + " instantiation " + cf); return responses; }