Class NodeProxy

    • Constructor Detail

      • NodeProxy

        public NodeProxy​(long nativeHandle)
        Creates a proxy of a node. Native code owns the node, and, therefore, shall destroy the object.
        Parameters:
        nativeHandle - an implementation-specific reference to a native node
    • Method Detail

      • submitTransaction

        public HashCode submitTransaction​(RawTransaction rawTransaction)
                                   throws InternalServerError
        Creates a transaction from the given parameters, signs it with the node service key, and then submits it into Exonum network. This node does not execute the transaction immediately, but broadcasts it to all the nodes in the network. Then each node verifies the transaction and, if it is correct, adds it to the pool of unconfirmed transactions. The transaction is executed later asynchronously.

        Incorrect transactions (e.g., the payload of which cannot be deserialized by the target service, or which have unknown message id) are rejected by the network.

        Be aware that each node has its own service key pair, therefore invocations of this method on different nodes will produce different transactions.

        Specified by:
        submitTransaction in interface Node
        Parameters:
        rawTransaction - transaction parameters to include in transaction message
        Returns:
        hash of the transaction message created by the framework
        Throws:
        IllegalStateException - if the node proxy is closed
        InternalServerError - if this node failed to process the transaction
        See Also:
        Blockchain.getTxMessages()
      • withSnapshot

        public <ResultT> ResultT withSnapshot​(Function<Snapshot,​ResultT> snapshotFunction)
        Performs a given function with a snapshot of the current database state.
        Specified by:
        withSnapshot in interface Node
        Type Parameters:
        ResultT - a type the function returns
        Parameters:
        snapshotFunction - a function to execute
        Returns:
        the result of applying the given function to the database state
        Throws:
        IllegalStateException - if the node proxy is closed