Class ATransaction

All Implemented Interfaces:
IValidated, IWriteable
Direct Known Subclasses:
Call, Invoke, Transfer

public abstract class ATransaction extends ACell
Abstract base class for immutable transactions Transactions may modify the on-chain State according to the rules of the specific transaction type. When applied to a State, a transaction must produce either: a) A valid updated State b) A TransactionException Any other class of exception should be regarded as a serious failure, indicating a code error or system integrity issue.
  • Field Details

    • address

      protected final Address address
    • sequence

      protected final long sequence
  • Constructor Details

    • ATransaction

      protected ATransaction(Address address, long sequence)
  • Method Details

    • encode

      public abstract int encode(byte[] bs, int pos)
      Writes this transaction to a byte array, including the message tag
      Specified by:
      encode in interface IWriteable
      Specified by:
      encode in class ACell
      Parameters:
      bs - A byte array to which to write the encoding
      pos - The offset into the byte array
      Returns:
      New position after writing
    • encodeRaw

      public int encodeRaw(byte[] bs, int pos)
      Description copied from class: ACell
      Writes this Cell's encoding to a byte array, excluding the tag byte
      Specified by:
      encodeRaw in class ACell
      Parameters:
      bs - A byte array to which to write the encoding
      pos - The offset into the byte array
      Returns:
      New position after writing
    • estimatedEncodingSize

      public abstract int estimatedEncodingSize()
      Description copied from interface: IWriteable
      Estimate the encoded data size for this Cell. Used for quickly sizing buffers. Implementations should try to return a size that is likely to contain the entire object when represented in binary format, including the tag byte.
      Returns:
      The estimated size for the binary representation of this object.
    • apply

      public abstract <T extends ACell> Context<T> apply(Context<?> ctx)
      Applies the functional effect of this transaction to the current state. Important points:
      • Assumes all relevant accounting preparation already complete, including juice reservation
      • Performs complete state update (including any rollbacks from errors)
      • Produces result, which may be exceptional
      • Does not finalise memory/juice accounting (will be completed afterwards)
      Parameters:
      ctx - Context for which to apply this Transaction
      Returns:
      The updated chain state
    • getAddress

      public Address getAddress()
      Gets the *origin* Address for this transaction
      Returns:
      Address for this Transaction
    • getSequence

      public final long getSequence()
    • getMaxJuice

      public abstract Long getMaxJuice()
      Gets the max juice allowed for this transaction
      Returns:
      Juice limit
    • isCVMValue

      public final boolean isCVMValue()
      Description copied from class: ACell
      Returns true if this object represents a first class CVM Value. Sub-structural cells that are not themselves first class values should return false. CVM values might not be in a canonical format, e.g. temporary data structures
      Specified by:
      isCVMValue in class ACell
      Returns:
      true if the object is a CVM Value, false otherwise
    • getType

      public AType getType()
      Description copied from class: ACell
      Gets the most specific known runtime Type for this Cell.
      Overrides:
      getType in class ACell
      Returns:
      The Type of this Call
    • withSequence

      public abstract ATransaction withSequence(long newSequence)
      Updates this transaction with the specified sequence number
      Parameters:
      newSequence - New sequence number
      Returns:
      Updated transaction, or this transaction if the sequence number is unchanged.
    • withAddress

      public abstract ATransaction withAddress(Address newAddress)
      Updates this transaction with the specified address
      Parameters:
      newAddress - New address
      Returns:
      Updated transaction, or this transaction if unchanged.
    • isCanonical

      public boolean isCanonical()
      Description copied from class: ACell
      Returns true if this Cell is in a canonical format for message writing. Reading or writing a non-canonical value should be considered illegal, but non-canonical objects may be used on a temporary internal basis.
      Specified by:
      isCanonical in class ACell
      Returns:
      true if the object is in canonical format, false otherwise
    • toCanonical

      public ACell toCanonical()
      Description copied from class: ACell
      Converts this Cell to its canonical version. Returns this if already canonical
      Specified by:
      toCanonical in class ACell
      Returns:
      Canonical version of Cell