public Response sendTransaction(Transaction transaction) throws PeerException {

        logger.debug("peer.sendTransaction");

        // Send the transaction to the peer node via grpc
        // The rpc specification on the peer side is:
        //     rpc ProcessTransaction(Transaction) returns (Response) {}
        Response response = peerClient.processTransaction(transaction.getTxBuilder().build());

        if (response.getStatus() != Response.StatusCode.SUCCESS) {
            return response;
        }

        logger.debug(String.format("peer.sendTransaction: received %s", response.getMsg().toStringUtf8()));

        // Check transaction type here, as invoke is an asynchronous call,
        // whereas a deploy and a query are synchonous calls. As such,
        // invoke will emit 'submitted' and 'error', while a deploy/query
        // will emit 'complete' and 'error'.

        Fabric.Transaction.Type txType = transaction.getTxBuilder().getType();
        switch (txType) {
            case CHAINCODE_DEPLOY: // async
                String txid = response.getMsg().toStringUtf8();
                // Deploy transaction has been completed
                if (txid == null || txid.isEmpty()) {
                    throw new ExecuteException("the deploy response is missing the transaction UUID");
                } else if (!this.waitForDeployComplete(txid)) {
                    throw new ExecuteException("the deploy request is submitted, but is not completed");
                } else {
                    return response;
                }
            case CHAINCODE_INVOKE: // async
                txid = response.getMsg().toStringUtf8();
                // Invoke transaction has been submitted
                if (txid == null || txid.isEmpty()) {
                    throw new ExecuteException("the invoke response is missing the transaction UUID");
                } else if(!this.waitForInvokeComplete(txid)) {
                    throw new ExecuteException("the invoke request is submitted, but is not completed");
                } else {
                    return response;
                }
            case CHAINCODE_QUERY: // sync
                return response;
            default: // not implemented
                throw new ExecuteException("processTransaction for this transaction type is not yet implemented!");
        }
    }
public Response sendTransaction ( Transaction transaction ) throws PeerException { logger . debug ( "peer.sendTransaction" ) ; Response response = peerClient . processTransaction ( transaction . getTxBuilder ( ) . build ( ) ) ; if ( response . getStatus ( ) != Response . StatusCode . SUCCESS ) { return response ; } logger . debug ( String . format ( "peer.sendTransaction: received %s" , response . getMsg ( ) . toStringUtf8 ( ) ) ) ; Fabric . Transaction . Type txType = transaction . getTxBuilder ( ) . getType ( ) ; switch ( txType ) { case CHAINCODE_DEPLOY : String txid = response . getMsg ( ) . toStringUtf8 ( ) ; if ( txid == null || txid . isEmpty ( ) ) { throw new ExecuteException ( "the deploy response is missing the transaction UUID" ) ; } else if ( ! this . waitForDeployComplete ( txid ) ) { throw new ExecuteException ( "the deploy request is submitted, but is not completed" ) ; } else { return response ; } case CHAINCODE_INVOKE : txid = response . getMsg ( ) . toStringUtf8 ( ) ; if ( txid == null || txid . isEmpty ( ) ) { throw new ExecuteException ( "the invoke response is missing the transaction UUID" ) ; } else if ( ! this . waitForInvokeComplete ( txid ) ) { throw new ExecuteException ( "the invoke request is submitted, but is not completed" ) ; } else { return response ; } case CHAINCODE_QUERY : return response ; default : throw new ExecuteException ( "processTransaction for this transaction type is not yet implemented!" ) ; } }
Send a transaction to this peer.
@param transaction A transaction
@throws PeerException