-
public interface NodeCachesThe caches of a local node.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description EngineClassLoadergetClassLoader(TransactionReference classpath)Yields a class loader for the given class path, using a cache to avoid regeneration, if possible.ConsensusParamsgetConsensusParams()Yields the consensus parameters of the node.Optional<BigInteger>getGasPrice()Yields the current gas price of the node.Optional<StorageReference>getGasStation()Yields the reference to the contract that keeps track of the gas cost.Optional<TransactionRequest<?>>getRequest(TransactionReference reference)Yields the request that generated the transaction with the given reference.Optional<TransactionResponse>getResponse(TransactionReference reference)Yields the response generated for the request for the given transaction.Optional<TransactionResponse>getResponseUncommitted(TransactionReference reference)Yields the response generated for the request for the given transaction.Optional<StorageReference>getValidators()Yields the reference to the contract that collects the validators of the node.Optional<StorageReference>getVersions()Yields the reference to the objects that keeps track of the versions of the modules of the node.voidinvalidate()Invalidates 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.voidrecomputeConsensus()Reconstructs the consensus parameters from information in the manifest.booleansignatureIsValid(SignedTransactionRequest request, SignatureAlgorithm<SignedTransactionRequest> signatureAlgorithm)Checks that the given request is signed with the private key of its caller.
-
-
-
Method Detail
-
invalidate
void invalidate()
Invalidates the information in this cache.
-
invalidateIfNeeded
void invalidateIfNeeded(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.- Parameters:
response- the responseclassLoader- the classloader
-
recomputeConsensus
void recomputeConsensus()
Reconstructs the consensus parameters from information in the manifest.
-
getRequest
Optional<TransactionRequest<?>> getRequest(TransactionReference reference)
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
Optional<TransactionResponse> getResponse(TransactionReference reference)
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
Optional<TransactionResponse> getResponseUncommitted(TransactionReference reference)
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)
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
-
signatureIsValid
boolean signatureIsValid(SignedTransactionRequest request, 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
-
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
-
-