- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
AbstractNode
A node of the Hotmoka network, that provides the storage
facilities for the execution of Takamaka code.
Calls to code in the node can be added, run or posted.
Posted calls are executed, eventually, and their value can be retrieved
through the future returned by the calls. Added calls are shorthand
for posting a call and waiting until the value of their future is
available. Run calls are only available for view methods, without side-effects.
They execute immediately and never modify the store of the node.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceNode.CodeSupplier<V extends StorageValue>The future of a transaction that executes code in a node.static interfaceThe future of a transaction that stores a jar in a node.static interface -
Method Summary
Modifier and TypeMethodDescriptionExpands this node's store with a transaction that runs a constructor of a class.Expands the store of this node with a transaction that creates a gamete, that is, a red/green externally owned contract with the given initial amount of coins, of classio.takamaka.code.lang.Gamete.voidExpands the store of this node with a transaction that marks the node as initialized and installs its manifest.Expands this node's store with a transaction that runs an instance method of an object already in this node's store.Expands the store of this node with a transaction that installs a jar in it.Expands the store of this node with a transaction that installs a jar in it.Expands this node's store with a transaction that runs a static method of a class in this node.getClassTag(StorageReference object) Yields the class tag of the object with the given storage reference.Yields the manifest installed in the store of the node.Yields the name of the algorithm used to sign requests with this node.Yields node-specific information about the node.getPolledResponse(TransactionReference reference) Waits until a transaction has been committed, or until its delivering fails.getRequest(TransactionReference reference) Yields the request that generated the transaction with the given reference.getResponse(TransactionReference reference) Yields the response generated for the request for the given transaction.getState(StorageReference object) Yields the current state of the object at the given storage reference.Yields the reference, in the store of the node, where the base Takamaka base classes are installed.Posts a transaction that runs a constructor of a class in this node.Posts a transaction that runs an instance method of an object already in this node's store.Posts a transaction that expands the store of this node with a transaction that installs a jar in it.Posts a request that runs a static method of a class in this node.Runs an instance@@Viewmethod of an object already in this node's store.Runs a static@@Viewmethod of a class in this node.subscribeToEvents(StorageReference creator, BiConsumer<StorageReference, StorageReference> handler) Subscribes the given handler for events with the given creator.Methods inherited from interface java.lang.AutoCloseable
close
-
Method Details
-
getTakamakaCode
Yields the reference, in the store of the node, where the base Takamaka base classes are installed. If this node has some form of commit, then this method returns a reference only if the installation of the jar with the Takamaka base classes has been already committed.- Throws:
NoSuchElementException- if the node has not been initialized yet
-
getManifest
Yields the manifest installed in the store of the node. The manifest is an object of typeio.takamaka.code.system.Manifestthat contains some information about the node, useful for the users of the node. If this node has some form of commit, then this method returns a reference only if the installation of the manifest has been already committed.- Returns:
- the reference to the node
- Throws:
NoSuchElementException- if no manifest has been set for this node
-
getNodeInfo
NodeInfo getNodeInfo()Yields node-specific information about the node. This is likely different for each node of the network, hence are out of consensus.- Returns:
- the node-specific information about the node
-
getClassTag
Yields the class tag of the object with the given storage reference. If this method succeeds and this node has some form of commit, then the transaction of the storage reference has been definitely committed in this node. A node is allowed to keep in store all, some or none of the objects. Hence, this method might fail to find the class tag although the object previously existed in store.- Parameters:
object- the storage reference of the object- Returns:
- the class tag, if any
- Throws:
NoSuchElementException- if there is no object with that reference or if the class tag could not be found
-
getState
Yields the current state of the object at the given storage reference. If this method succeeds and this node has some form of commit, then the transaction of the storage reference has been definitely committed in this node. A node is allowed to keep in store all, some or none of the objects. Hence, this method might fail to find the state of the object although the object previously existed in store.- Parameters:
object- the storage reference of the object- Returns:
- the last updates of all its instance fields; these updates include the class tag update for the object
- Throws:
NoSuchElementException- if there is no object with that reference
-
getNameOfSignatureAlgorithmForRequests
String getNameOfSignatureAlgorithmForRequests()Yields the name of the algorithm used to sign requests with this node.- Returns:
- the name of the algorithm
-
getRequest
Yields the request that generated the transaction with the given reference. If this node has some form of commit, then this method can only succeed when the transaction has been definitely committed in this node. Nodes are allowed to keep in store all, some or none of the requests that they received during their lifetime.- Parameters:
reference- the reference of the transaction- Returns:
- the request
- Throws:
NoSuchElementException- if there is no request with that reference
-
getResponse
TransactionResponse getResponse(TransactionReference reference) throws TransactionRejectedException, NoSuchElementException Yields the response generated for the request for the given transaction. If this node has some form of commit, then this method can only succeed or yield a TransactionRejectedException only when the transaction has been definitely committed in this node. Nodes are allowed to keep in store all, some or none of the responses that they computed during their lifetime.- Parameters:
reference- the reference of the transaction- Returns:
- the response
- Throws:
TransactionRejectedException- if there is a request for that transaction but it failed with this exceptionNoSuchElementException- if there is no request, and hence no response, with that reference
-
getPolledResponse
TransactionResponse getPolledResponse(TransactionReference reference) throws TransactionRejectedException, TimeoutException, InterruptedException Waits until a transaction has been committed, or until its delivering fails. If this method succeeds and this node has some form of commit, then the transaction has been definitely committed. Nodes are allowed to keep in store all, some or none of the responses computed during their lifetime. Hence, this method might time out also when a response has been computed in the past for the transaction ofreference, but it has not been kept in store.- Parameters:
reference- the reference of the transaction- Returns:
- the response computed for
request - Throws:
TransactionRejectedException- if the request failed to be committed, because of this exceptionTimeoutException- if the polling delay has expired but the request did not get committedInterruptedException- if the current thread has been interrupted while waiting for the response
-
addJarStoreInitialTransaction
TransactionReference addJarStoreInitialTransaction(JarStoreInitialTransactionRequest request) throws TransactionRejectedException Expands the store of this node with a transaction that installs a jar in it. It has no caller and requires no gas. The goal is to install, in the node, some basic jars that are likely needed as dependencies by future jars. For instance, the jar containing the basic contract classes. This installation have special privileges, such as that of installing packages inio.takamaka.code.lang.*.- Parameters:
request- the transaction request- Returns:
- the reference to the transaction, that can be used to refer to the jar in a class path or as future dependency of other jars
- Throws:
TransactionRejectedException- if the transaction could not be executed and the store of the node remained unchanged
-
addGameteCreationTransaction
StorageReference addGameteCreationTransaction(GameteCreationTransactionRequest request) throws TransactionRejectedException Expands the store of this node with a transaction that creates a gamete, that is, a red/green externally owned contract with the given initial amount of coins, of classio.takamaka.code.lang.Gamete. This transaction has no caller and requires no gas.- Parameters:
request- the transaction request- Returns:
- the reference to the freshly created gamete
- Throws:
TransactionRejectedException- if the transaction could not be executed and the store of the node remained unchanged
-
addInitializationTransaction
void addInitializationTransaction(InitializationTransactionRequest request) throws TransactionRejectedException Expands the store of this node with a transaction that marks the node as initialized and installs its manifest. After this transaction, no more initial transactions can be executed on the node.- Parameters:
request- the transaction request- Throws:
TransactionRejectedException- if the transaction could not be executed and the store of the node remained unchanged
-
addJarStoreTransaction
TransactionReference addJarStoreTransaction(JarStoreTransactionRequest request) throws TransactionRejectedException, TransactionException Expands the store of this node with a transaction that installs a jar in it.- Parameters:
request- the transaction request- Returns:
- the reference to the transaction, that can be used to refer to the jar in a class path or as future dependency of other jars
- Throws:
TransactionRejectedException- if the transaction could not be executed and the store of the node remained unchangedTransactionException- if the transaction could be executed and the store of the node has been expanded with a failed transaction
-
addConstructorCallTransaction
StorageReference addConstructorCallTransaction(ConstructorCallTransactionRequest request) throws TransactionRejectedException, TransactionException, CodeExecutionException Expands this node's store with a transaction that runs a constructor of a class.- Parameters:
request- the request of the transaction- Returns:
- the created object, if the constructor was successfully executed, without exception
- Throws:
TransactionRejectedException- if the transaction could not be executed and the store of the node remained unchangedCodeExecutionException- if the transaction could be executed and the node has been expanded with a failed transaction, because of an exception in the user code in blockchain, that is allowed to be thrown by the constructorTransactionException- if the transaction could be executed and the node has been expanded with a failed transaction, because of an exception outside the user code in blockchain, or not allowed to be thrown by the constructor
-
addInstanceMethodCallTransaction
StorageValue addInstanceMethodCallTransaction(InstanceMethodCallTransactionRequest request) throws TransactionRejectedException, TransactionException, CodeExecutionException Expands this node's store with a transaction that runs an instance method of an object already in this node's store.- Parameters:
request- the transaction request- Returns:
- the result of the call, if the method was successfully executed, without exception. If the method is
declared to return
void, this result will benull - Throws:
TransactionRejectedException- if the transaction could not be executed and the store of the node remained unchangedCodeExecutionException- if the transaction could be executed and the node has been expanded with a failed transaction, because of an exception in the user code in blockchain, that is allowed to be thrown by the methodTransactionException- if the transaction could be executed and the node has been expanded with a failed transaction, because of an exception outside the user code in blockchain, or not allowed to be thrown by the method
-
addStaticMethodCallTransaction
StorageValue addStaticMethodCallTransaction(StaticMethodCallTransactionRequest request) throws TransactionRejectedException, TransactionException, CodeExecutionException Expands this node's store with a transaction that runs a static method of a class in this node.- Parameters:
request- the transaction request- Returns:
- the result of the call, if the method was successfully executed, without exception. If the method is
declared to return
void, this result will benull - Throws:
TransactionRejectedException- if the transaction could not be executed and the store of the node remained unchangedCodeExecutionException- if the transaction could be executed and the node has been expanded with a failed transaction, because of an exception in the user code in blockchain, that is allowed to be thrown by the methodTransactionException- if the transaction could be executed and the node has been expanded with a failed transaction, because of an exception outside the user code in blockchain, or not allowed to be thrown by the method
-
runInstanceMethodCallTransaction
StorageValue runInstanceMethodCallTransaction(InstanceMethodCallTransactionRequest request) throws TransactionRejectedException, TransactionException, CodeExecutionException Runs an instance@@Viewmethod of an object already in this node's store. The node's store is not expanded, since the execution of the method has no side-effects.- Parameters:
request- the transaction request- Returns:
- the result of the call, if the method was successfully executed, without exception
- Throws:
TransactionRejectedException- if the transaction could not be executedCodeExecutionException- if the transaction could be executed but led to an exception in the user code in blockchain, that is allowed to be thrown by the methodTransactionException- if the transaction could be executed but led to an exception outside the user code in blockchain, or that is not allowed to be thrown by the method
-
runStaticMethodCallTransaction
StorageValue runStaticMethodCallTransaction(StaticMethodCallTransactionRequest request) throws TransactionRejectedException, TransactionException, CodeExecutionException Runs a static@@Viewmethod of a class in this node. The node's store is not expanded, since the execution of the method has no side-effects.- Parameters:
request- the transaction request- Returns:
- the result of the call, if the method was successfully executed, without exception
- Throws:
TransactionRejectedException- if the transaction could not be executedCodeExecutionException- if the transaction could be executed but led to an exception in the user code in blockchain, that is allowed to be thrown by the methodTransactionException- if the transaction could be executed but led to an exception outside the user code in blockchain, or that is not allowed to be thrown by the method
-
postJarStoreTransaction
Node.JarSupplier postJarStoreTransaction(JarStoreTransactionRequest request) throws TransactionRejectedException Posts a transaction that expands the store of this node with a transaction that installs a jar in it.- Parameters:
request- the transaction request- Returns:
- the future holding the reference to the transaction where the jar has been installed
- Throws:
TransactionRejectedException- if the transaction could not be posted
-
postConstructorCallTransaction
Node.CodeSupplier<StorageReference> postConstructorCallTransaction(ConstructorCallTransactionRequest request) throws TransactionRejectedException Posts a transaction that runs a constructor of a class in this node.- Parameters:
request- the request of the transaction- Returns:
- the future holding the result of the computation
- Throws:
TransactionRejectedException- if the transaction could not be posted
-
postInstanceMethodCallTransaction
Node.CodeSupplier<StorageValue> postInstanceMethodCallTransaction(InstanceMethodCallTransactionRequest request) throws TransactionRejectedException Posts a transaction that runs an instance method of an object already in this node's store.- Parameters:
request- the transaction request- Returns:
- the future holding the result of the transaction
- Throws:
TransactionRejectedException- if the transaction could not be posted
-
postStaticMethodCallTransaction
Node.CodeSupplier<StorageValue> postStaticMethodCallTransaction(StaticMethodCallTransactionRequest request) throws TransactionRejectedException Posts a request that runs a static method of a class in this node.- Parameters:
request- the transaction request- Returns:
- the future holding the result of the transaction
- Throws:
TransactionRejectedException- if the transaction could not be posted
-
subscribeToEvents
Node.Subscription subscribeToEvents(StorageReference creator, BiConsumer<StorageReference, StorageReference> handler) Subscribes the given handler for events with the given creator.- Parameters:
creator- the creator of the events that will be forwarded to the handler; if this isnull, all events will be forwarded to the handlerhandler- a handler that gets executed when an event with the given creator occurs; a handler can be subscribed to more creators; for each event, it receives its creator and the event itself- Returns:
- the subscription, that can be used later to stop event handling with
handler
-