Class NonInitialResponseBuilder.ResponseCreator

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
  • Constructor Details

  • Method Details

    • init

      protected final void init()
    • deserializedPayer

      protected Object deserializedPayer()
      Yields the contract that pays for the transaction. This normally coincides with getDeserializedCaller() but subclasses may redefine.
      Returns:
      the payer for the transaction
    • getDeserializedCaller

      protected final Object getDeserializedCaller()
      Yields the deserialized caller of the transaction.
      Returns:
      the deserialized caller
    • getDeserializedValidators

      protected final Optional<Object> 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

      protected final BigInteger gasConsumedForCPU()
      Yields the amount of gas consumed for CPU execution.
      Returns:
      the amount of gas
    • gasConsumedForRAM

      protected final BigInteger gasConsumedForRAM()
      Yields the amount of gas consumed for RAM allocation.
      Returns:
      the amount of gas
    • gasConsumedForStorage

      protected final BigInteger gasConsumedForStorage()
      Yields the amount of gas consumed for storage consumption.
      Returns:
      the amount of gas
    • gasConsumedForPenalty

      protected final BigInteger 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

      protected final void chargeGasForStorageOf(Response response)
      Decreases the available gas for the given response, for storage allocation.
      Parameters:
      response - the response
    • chargeGasForCPU

      public final void chargeGasForCPU(BigInteger amount)
      Description copied from class: io.hotmoka.local.internal.transactions.AbstractResponseBuilder.ResponseCreator
      Decreases the available gas by the given amount, for CPU execution.
      Specified by:
      chargeGasForCPU in class io.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

      public final void chargeGasForRAM(BigInteger amount)
      Description copied from class: io.hotmoka.local.internal.transactions.AbstractResponseBuilder.ResponseCreator
      Decreases the available gas by the given amount, for RAM execution.
      Specified by:
      chargeGasForRAM in class io.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

      protected final Stream<Update> updatesToBalanceOrNonceOfCaller()
      Collects all updates to the balance or nonce of the caller of the transaction.
      Returns:
      the updates
    • isUpdateToBalanceOrNonceOfCaller

      protected final boolean isUpdateToBalanceOrNonceOfCaller(Update update)
      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

      public final <T> T withGas(BigInteger amount, Callable<T> what) throws Exception
      Description copied from class: io.hotmoka.local.internal.transactions.AbstractResponseBuilder.ResponseCreator
      Runs 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:
      withGas in class io.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 code
      what - the code to run
      Returns:
      the result of the execution of the code
      Throws:
      Exception - if the code runs into this exception