java.lang.Object
io.hotmoka.local.internal.transactions.AbstractResponseBuilder<Request,Response>.io.hotmoka.local.internal.transactions.AbstractResponseBuilder.ResponseCreator
io.hotmoka.local.NonInitialResponseBuilder.ResponseCreator
- Enclosing class:
NonInitialResponseBuilder<Request extends NonInitialTransactionRequest<Response>,Response extends NonInitialTransactionResponse>
protected abstract class NonInitialResponseBuilder.ResponseCreator
extends io.hotmoka.local.internal.transactions.AbstractResponseBuilder<Request,Response>.io.hotmoka.local.internal.transactions.AbstractResponseBuilder.ResponseCreator
-
Field Summary
Fields inherited from class io.hotmoka.local.internal.transactions.AbstractResponseBuilder.ResponseCreator
deserializer, updatesExtractor -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final voidCharges gas proportional to the complexity of the class loader that has been created.final voidchargeGasForCPU(BigInteger amount) Decreases the available gas by the given amount, for CPU execution.final voidchargeGasForRAM(BigInteger amount) Decreases the available gas by the given amount, for RAM execution.protected final voidchargeGasForStorageOf(Response response) Decreases the available gas for the given response, for storage allocation.protected ObjectYields the contract that pays for the transaction.protected final BigIntegerYields the amount of gas consumed for CPU execution.protected final BigIntegerYields the gas that would be paid if the transaction fails.protected final BigIntegerYields the amount of gas consumed for RAM allocation.protected final BigIntegerYields the amount of gas consumed for storage consumption.protected final ObjectYields the deserialized caller of the transaction.Yields the contract that collects the validators of the node.protected final voidinit()protected final booleanDetermines if the given update affects the balance or the nonce of the caller of the transaction.protected final voidPays back the remaining gas to the payer of the transaction.protected final voidCollects all updates to the balance or nonce of the caller of the transaction.final <T> TwithGas(BigInteger amount, Callable<T> what) Runs a given piece of code with a subset of the available gas.Methods inherited from class io.hotmoka.local.internal.transactions.AbstractResponseBuilder.ResponseCreator
addToTotalSupply, body, canCallMintBurnFromGamete, create, deserializeLastUpdateFor, deserializeLastUpdateForFinal, event, extractUpdatesFrom, getClassLoader, getNextStorageReference, isSystemCall, now
-
Constructor Details
-
ResponseCreator
- Throws:
TransactionRejectedException
-
-
Method Details
-
init
protected final void init() -
deserializedPayer
Yields the contract that pays for the transaction. This normally coincides withgetDeserializedCaller()but subclasses may redefine.- Returns:
- the payer for the transaction
-
getDeserializedCaller
Yields the deserialized caller of the transaction.- Returns:
- the deserialized caller
-
getDeserializedValidators
Yields 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.- Returns:
- the contract, inside the store of the node, if the node is already initialized
-
gasConsumedForCPU
Yields the amount of gas consumed for CPU execution.- Returns:
- the amount of gas
-
gasConsumedForRAM
Yields the amount of gas consumed for RAM allocation.- Returns:
- the amount of gas
-
gasConsumedForStorage
Yields the amount of gas consumed for storage consumption.- Returns:
- the amount of gas
-
gasConsumedForPenalty
Yields the gas that would be paid if the transaction fails.- Returns:
- the gas for penalty, computed as the total initial gas minus the gas already consumed for PCU, for RAM and for storage
-
chargeGasForStorageOf
Decreases the available gas for the given response, for storage allocation.- Parameters:
response- the response
-
chargeGasForCPU
Description copied from class:io.hotmoka.local.internal.transactions.AbstractResponseBuilder.ResponseCreatorDecreases the available gas by the given amount, for CPU execution.- Specified by:
chargeGasForCPUin classio.hotmoka.local.internal.transactions.AbstractResponseBuilder<Request extends NonInitialTransactionRequest<Response>,Response extends NonInitialTransactionResponse>.io.hotmoka.local.internal.transactions.AbstractResponseBuilder.ResponseCreator - Parameters:
amount- the amount of gas to consume
-
chargeGasForRAM
Description copied from class:io.hotmoka.local.internal.transactions.AbstractResponseBuilder.ResponseCreatorDecreases the available gas by the given amount, for RAM execution.- Specified by:
chargeGasForRAMin classio.hotmoka.local.internal.transactions.AbstractResponseBuilder<Request extends NonInitialTransactionRequest<Response>,Response extends NonInitialTransactionResponse>.io.hotmoka.local.internal.transactions.AbstractResponseBuilder.ResponseCreator - Parameters:
amount- the amount of gas to consume
-
chargeGasForClassLoader
protected final void chargeGasForClassLoader()Charges gas proportional to the complexity of the class loader that has been created. -
updatesToBalanceOrNonceOfCaller
Collects all updates to the balance or nonce of the caller of the transaction.- Returns:
- the updates
-
isUpdateToBalanceOrNonceOfCaller
Determines if the given update affects the balance or the nonce of the caller of the transaction. Those are the only updates that are allowed during the execution of a view method.- Parameters:
update- the update- Returns:
- true if and only if that condition holds
-
refundPayerForAllRemainingGas
protected final void refundPayerForAllRemainingGas()Pays back the remaining gas to the payer of the transaction. -
resetBalanceOfPayerToInitialValueMinusAllPromisedGas
protected final void resetBalanceOfPayerToInitialValueMinusAllPromisedGas() -
withGas
Description copied from class:io.hotmoka.local.internal.transactions.AbstractResponseBuilder.ResponseCreatorRuns a given piece of code with a subset of the available gas. It first charges the given amount of gas. Then runs the code with the charged gas only. At its end, the remaining gas is added to the available gas to continue the computation.- Specified by:
withGasin classio.hotmoka.local.internal.transactions.AbstractResponseBuilder<Request extends NonInitialTransactionRequest<Response>,Response extends NonInitialTransactionResponse>.io.hotmoka.local.internal.transactions.AbstractResponseBuilder.ResponseCreator - Parameters:
amount- the amount of gas provided to the codewhat- the code to run- Returns:
- the result of the execution of the code
- Throws:
Exception- if the code runs into this exception
-