Search in sources :

Example 6 with InstallProposalBuilder

use of org.hyperledger.fabric.sdk.transaction.InstallProposalBuilder in project fabric-sdk-java by hyperledger.

the class Channel method sendInstallProposal.

/**
 * Send install chaincode request proposal to the channel.
 *
 * @param installProposalRequest
 * @param peers
 * @return
 * @throws ProposalException
 * @throws InvalidArgumentException
 */
Collection<ProposalResponse> sendInstallProposal(InstallProposalRequest installProposalRequest, Collection<Peer> peers) throws ProposalException, InvalidArgumentException {
    checkChannelState();
    checkPeers(peers);
    if (null == installProposalRequest) {
        throw new InvalidArgumentException("InstallProposalRequest is null");
    }
    try {
        TransactionContext transactionContext = getTransactionContext(installProposalRequest.getUserContext());
        // Install will have no signing cause it's not really targeted to a channel.
        transactionContext.verify(false);
        transactionContext.setProposalWaitTime(installProposalRequest.getProposalWaitTime());
        InstallProposalBuilder installProposalbuilder = InstallProposalBuilder.newBuilder();
        installProposalbuilder.context(transactionContext);
        installProposalbuilder.setChaincodeLanguage(installProposalRequest.getChaincodeLanguage());
        installProposalbuilder.chaincodeName(installProposalRequest.getChaincodeName());
        installProposalbuilder.chaincodePath(installProposalRequest.getChaincodePath());
        installProposalbuilder.chaincodeVersion(installProposalRequest.getChaincodeVersion());
        installProposalbuilder.setChaincodeSource(installProposalRequest.getChaincodeSourceLocation());
        installProposalbuilder.setChaincodeInputStream(installProposalRequest.getChaincodeInputStream());
        installProposalbuilder.setChaincodeMetaInfLocation(installProposalRequest.getChaincodeMetaInfLocation());
        FabricProposal.Proposal deploymentProposal = installProposalbuilder.build();
        SignedProposal signedProposal = getSignedProposal(transactionContext, deploymentProposal);
        return sendProposalToPeers(peers, signedProposal, transactionContext);
    } catch (Exception e) {
        throw new ProposalException(e);
    }
}
Also used : FabricProposal(org.hyperledger.fabric.protos.peer.FabricProposal) InvalidArgumentException(org.hyperledger.fabric.sdk.exception.InvalidArgumentException) InstallProposalBuilder(org.hyperledger.fabric.sdk.transaction.InstallProposalBuilder) TransactionContext(org.hyperledger.fabric.sdk.transaction.TransactionContext) SignedProposal(org.hyperledger.fabric.protos.peer.FabricProposal.SignedProposal) ProposalException(org.hyperledger.fabric.sdk.exception.ProposalException) EventHubException(org.hyperledger.fabric.sdk.exception.EventHubException) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) InvalidArgumentException(org.hyperledger.fabric.sdk.exception.InvalidArgumentException) TransactionException(org.hyperledger.fabric.sdk.exception.TransactionException) TransactionEventException(org.hyperledger.fabric.sdk.exception.TransactionEventException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) StatusRuntimeException(io.grpc.StatusRuntimeException) CryptoException(org.hyperledger.fabric.sdk.exception.CryptoException) TimeoutException(java.util.concurrent.TimeoutException) ProposalException(org.hyperledger.fabric.sdk.exception.ProposalException)

Aggregations

InstallProposalBuilder (org.hyperledger.fabric.sdk.transaction.InstallProposalBuilder)6 TransactionContext (org.hyperledger.fabric.sdk.transaction.TransactionContext)6 File (java.io.File)5 Test (org.junit.Test)5 FabricProposal (org.hyperledger.fabric.protos.peer.FabricProposal)4 ByteString (com.google.protobuf.ByteString)2 ArrayList (java.util.ArrayList)2 Chaincode (org.hyperledger.fabric.protos.peer.Chaincode)2 TestUtils.tarBytesToEntryArrayList (org.hyperledger.fabric.sdk.testutils.TestUtils.tarBytesToEntryArrayList)2 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)1 StatusRuntimeException (io.grpc.StatusRuntimeException)1 IOException (java.io.IOException)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1 SignedProposal (org.hyperledger.fabric.protos.peer.FabricProposal.SignedProposal)1 CryptoException (org.hyperledger.fabric.sdk.exception.CryptoException)1 EventHubException (org.hyperledger.fabric.sdk.exception.EventHubException)1 InvalidArgumentException (org.hyperledger.fabric.sdk.exception.InvalidArgumentException)1 ProposalException (org.hyperledger.fabric.sdk.exception.ProposalException)1 TransactionEventException (org.hyperledger.fabric.sdk.exception.TransactionEventException)1