Class HFClient



  • public class HFClient
    extends java.lang.Object
    • Field Detail

      • executorService

        protected final java.util.concurrent.ExecutorService executorService
      • threadFactory

        protected final java.util.concurrent.ThreadFactory threadFactory
    • Method Detail

      • getUserContext

        public User getUserContext​()
      • getCryptoSuite

        public CryptoSuite getCryptoSuite​()
      • createNewInstance

        public static HFClient createNewInstance​()
        createNewInstance create a new instance of the HFClient
        Returns:
        client
      • loadChannelFromConfig

        public Channel loadChannelFromConfig​(java.lang.String channelName,
                                             NetworkConfig networkConfig)
                                      throws InvalidArgumentException,
                                             NetworkConfigurationException
        Configures a channel based on information loaded from a Network Config file. Note that it is up to the caller to initialize the returned channel.
        Parameters:
        channelName - The name of the channel to be configured
        networkConfig - The network configuration to use to configure the channel
        Returns:
        The configured channel, or null if the channel is not defined in the configuration
        Throws:
        InvalidArgumentException
        NetworkConfigurationException
      • deSerializeChannel

        public Channel deSerializeChannel​(java.io.File file)
                                   throws java.io.IOException,
                                          java.lang.ClassNotFoundException,
                                          InvalidArgumentException
        Deserialize a channel serialized by Channel.serializeChannel()
        Parameters:
        file - a file which contains the bytes to be deserialized.
        Returns:
        A Channel that has not been initialized.
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException
        InvalidArgumentException
      • deSerializeChannel

        public Channel deSerializeChannel​(byte[] channelBytes)
                                   throws java.io.IOException,
                                          java.lang.ClassNotFoundException,
                                          InvalidArgumentException
        Deserialize a channel serialized by Channel.serializeChannel()
        Parameters:
        channelBytes - bytes to be deserialized.
        Returns:
        A Channel that has not been initialized.
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException
        InvalidArgumentException
      • newPeer

        public Peer newPeer​(java.lang.String name,
                            java.lang.String grpcURL,
                            java.util.Properties properties)
                     throws InvalidArgumentException
        newPeer create a new peer
        Parameters:
        name - name of peer.
        grpcURL - to the peer's location
        properties -

        Supported properties

        • pemFile - File location for x509 pem certificate for SSL.
        • pemBytes - byte array for x509 pem certificates for SSL
        • trustServerCertificate - boolen(true/false) override CN to match pemFile certificate -- for development only. If the pemFile has the target server's certificate (instead of a CA Root certificate), instruct the TLS client to trust the CN value of the certificate in the pemFile, useful in development to get past default server hostname verification during TLS handshake, when the server host name does not match the certificate.
        • clientKeyFile - File location for private key pem for mutual TLS
        • clientCertFile - File location for x509 pem certificate for mutual TLS
        • clientKeyBytes - Private key pem bytes for mutual TLS
        • clientCertBytes - x509 pem certificate bytes for mutual TLS
        • hostnameOverride - Specify the certificates CN -- for development only.
        • sslProvider - Specify the SSL provider, openSSL or JDK.
        • negotiationType - Specify the type of negotiation, TLS or plainText.
        • If the pemFile does not represent the server certificate, use this property to specify the URI authority (a.k.a hostname) expected in the target server's certificate. This is required to get past default server hostname verifications during TLS handshake.
        • peerEventRegistrationWaitTime - Time in milliseconds to wait for peer eventing service registration.
        • grpc.NettyChannelBuilderOption.<methodName> where methodName is any method on grpc ManagedChannelBuilder. If more than one argument to the method is needed then the parameters need to be supplied in an array of Objects.
        Returns:
        Peer
        Throws:
        InvalidArgumentException
      • getChannel

        public Channel getChannel​(java.lang.String name)
        getChannel by name
        Parameters:
        name - The channel name
        Returns:
        a channel (or null if the channel does not exist)
      • newInstallProposalRequest

        public InstallProposalRequest newInstallProposalRequest​()
        newInstallProposalRequest get new Install proposal request.
        Returns:
        InstallProposalRequest
      • newInstantiationProposalRequest

        public InstantiateProposalRequest newInstantiationProposalRequest​()
        newInstantiationProposalRequest get new instantiation proposal request.
        Returns:
        InstantiateProposalRequest
      • newTransactionProposalRequest

        public TransactionProposalRequest newTransactionProposalRequest​()
        newTransactionProposalRequest get new transaction proposal request.
        Returns:
        TransactionProposalRequest
      • newQueryProposalRequest

        public QueryByChaincodeRequest newQueryProposalRequest​()
        newQueryProposalRequest get new query proposal request.
        Returns:
        QueryByChaincodeRequest
      • newEventHub

        public EventHub newEventHub​(java.lang.String name,
                                    java.lang.String grpcURL,
                                    java.util.Properties properties)
                             throws InvalidArgumentException
        Create a new Eventhub.
        Parameters:
        name - name of Eventhub.
        grpcURL - url location of orderer grpc or grpcs protocol.
        properties -

        Supported properties

        • pemFile - File location for x509 pem certificate for SSL.
        • pemBytes - byte array for x509 pem certificates for SSL
        • trustServerCertificate - boolean(true/false) override CN to match pemFile certificate -- for development only. If the pemFile has the target server's certificate (instead of a CA Root certificate), instruct the TLS client to trust the CN value of the certificate in the pemFile, useful in development to get past default server hostname verification during TLS handshake, when the server host name does not match the certificate.
        • clientKeyFile - File location for PKCS8-encoded private key pem for mutual TLS
        • clientCertFile - File location for x509 pem certificate for mutual TLS
        • hostnameOverride - Specify the certificates CN -- for development only.
        • sslProvider - Specify the SSL provider, openSSL or JDK.
        • negotiationType - Specify the type of negotiation, TLS or plainText.
        • If the pemFile does not represent the server certificate, use this property to specify the URI authority (a.k.a hostname) expected in the target server's certificate. This is required to get past default server hostname verifications during TLS handshake.
        • grpc.NettyChannelBuilderOption.<methodName> where methodName is any method on grpc ManagedChannelBuilder. If more than one argument to the method is needed then the parameters need to be supplied in an array of Objects.
        Returns:
        The orderer.
        Throws:
        InvalidArgumentException
      • newEventHub

        public EventHub newEventHub​(java.lang.String name,
                                    java.lang.String grpcURL)
                             throws InvalidArgumentException
        Create a new event hub
        Parameters:
        name - Name of eventhup should match peer's name it's associated with.
        grpcURL - The http url location of the event hub
        Returns:
        event hub
        Throws:
        InvalidArgumentException
      • newOrderer

        public Orderer newOrderer​(java.lang.String name,
                                  java.lang.String grpcURL)
                           throws InvalidArgumentException
        Create a new urlOrderer.
        Parameters:
        name - name of the orderer.
        grpcURL - url location of orderer grpc or grpcs protocol.
        Returns:
        a new Orderer.
        Throws:
        InvalidArgumentException
      • newOrderer

        public Orderer newOrderer​(java.lang.String name,
                                  java.lang.String grpcURL,
                                  java.util.Properties properties)
                           throws InvalidArgumentException
        Create a new orderer.
        Parameters:
        name - name of Orderer.
        grpcURL - url location of orderer grpc or grpcs protocol.
        properties -

        Supported properties

        • pemFile - File location for x509 pem certificate for SSL.
        • pemBytes - byte array for x509 pem certificates for SSL
        • trustServerCertificate - boolean(true/false) override CN to match pemFile certificate -- for development only. If the pemFile has the target server's certificate (instead of a CA Root certificate), instruct the TLS client to trust the CN value of the certificate in the pemFile, useful in development to get past default server hostname verification during TLS handshake, when the server host name does not match the certificate.
        • clientKeyFile - File location for private key pem for mutual TLS
        • clientCertFile - File location for x509 pem certificate for mutual TLS
        • clientKeyBytes - Private key pem bytes for mutual TLS
        • clientCertBytes - x509 pem certificate bytes for mutual TLS
        • sslProvider - Specify the SSL provider, openSSL or JDK.
        • negotiationType - Specify the type of negotiation, TLS or plainText.
        • hostnameOverride - Specify the certificates CN -- for development only. If the pemFile does not represent the server certificate, use this property to specify the URI authority (a.k.a hostname) expected in the target server's certificate. This is required to get past default server hostname verifications during TLS handshake.
        • grpc.NettyChannelBuilderOption.<methodName> where methodName is any method on grpc ManagedChannelBuilder. If more than one argument to the method is needed then the parameters need to be supplied in an array of Objects.
        • ordererWaitTimeMilliSecs Time to wait in milliseconds for the Orderer to accept requests before timing out. The default is two seconds.
        Returns:
        The orderer.
        Throws:
        InvalidArgumentException