public interface NodeCaches
The caches of a local node.
-
Method Summary
Modifier and TypeMethodDescriptiongetClassLoader(TransactionReference classpath) Yields a class loader for the given class path, using a cache to avoid regeneration, if possible.Yields the consensus parameters of the node.Yields the current inflation of the node.Yields the reference to the gamete account of the node.Yields the current gas price of the node.Yields the reference to the contract that keeps track of the gas cost.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.getResponseUncommitted(TransactionReference reference) Yields the response generated for the request for the given transaction.Yields the reference to the contract that collects the validators of the node.Yields the reference to the objects that keeps track of the versions of the modules of the node.voidInvalidates the information in this cache.voidinvalidateIfNeeded(TransactionResponse response, EngineClassLoader classLoader) Invalidates the information in this cache, after the execution of a transaction with the given classloader, that yielded the given response.voidReconstructs the consensus parameters from information in the manifest.booleansignatureIsValid(SignedTransactionRequest request, io.hotmoka.crypto.api.SignatureAlgorithm<SignedTransactionRequest> signatureAlgorithm) Checks that the given request is signed with the private key of its caller.
-
Method Details
-
invalidate
void invalidate()Invalidates the information in this cache. -
invalidateIfNeeded
void invalidateIfNeeded(TransactionResponse response, EngineClassLoader classLoader) throws ClassNotFoundException Invalidates the information in this cache, after the execution of a transaction with the given classloader, that yielded the given response.- Parameters:
response- the responseclassLoader- the classloader- Throws:
ClassNotFoundException- if some class of the Takamaka program cannot be found
-
recomputeConsensus
void recomputeConsensus()Reconstructs the consensus parameters from information in the manifest. -
getRequest
Yields the request that generated the transaction with the given reference. If the node has some form of commit, then this method can only succeed when the transaction has been definitely committed in the 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, if any
-
getResponse
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 when the transaction has been definitely committed in the 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, if any
-
getResponseUncommitted
Yields the response generated for the request for the given transaction. If this node has some form of commit, then this method succeeds also if the transaction has not been committed yet in the 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, if any
-
getClassLoader
EngineClassLoader getClassLoader(TransactionReference classpath) throws ClassNotFoundException, UnsupportedVerificationVersionException, IOException Yields a class loader for the given class path, using a cache to avoid regeneration, if possible.- Parameters:
classpath- the class path that must be used by the class loader- Returns:
- the class loader
- Throws:
ClassNotFoundException- if some class of the Takamaka runtime cannot be loadedUnsupportedVerificationVersionException- if the verification version is not supportedIOException- if there was an I/O error while accessing some jar
-
signatureIsValid
boolean signatureIsValid(SignedTransactionRequest request, io.hotmoka.crypto.api.SignatureAlgorithm<SignedTransactionRequest> signatureAlgorithm) throws Exception Checks that the given request is signed with the private key of its caller. It uses a cache to remember the last signatures already checked.- Parameters:
request- the requestsignatureAlgorithm- the algorithm that must have been used for signing the request- Returns:
- true if and only if the signature of
requestis valid - Throws:
Exception- if the signature of the request could not be checked
-
getConsensusParams
ConsensusParams getConsensusParams()Yields the consensus parameters of the node.- Returns:
- the consensus parameters
-
getGamete
Optional<StorageReference> getGamete()Yields the reference to the gamete account of the node. This method uses a cache to avoid repeated computations.- Returns:
- the reference to the gamete account, if the node is already initialized
-
getValidators
Optional<StorageReference> getValidators()Yields the reference to the contract that collects the validators of the node. After each transaction that consumes gas, the price of the gas is sent to this contract, that can later redistribute the reward to all validators. This method uses a cache to avoid repeated computations.- Returns:
- the reference to the contract, if the node is already initialized
-
getVersions
Optional<StorageReference> getVersions()Yields the reference to the objects that keeps track of the versions of the modules of the node.- Returns:
- the reference to the object, if the node is already initialized
-
getGasStation
Optional<StorageReference> getGasStation()Yields the reference to the contract that keeps track of the gas cost.- Returns:
- the reference to the contract, if the node is already initialized
-
getGasPrice
Optional<BigInteger> getGasPrice()Yields the current gas price of the node.- Returns:
- the current gas price of the node, if the node is already initialized
-
getCurrentInflation
Yields the current inflation of the node.- Returns:
- the current inflation of the node, if the node is already initialized
-