Class ATransaction

All Implemented Interfaces:
IAssociative<Keyword,ACell>, IValidated, IWriteable, Map<Keyword,ACell>
Direct Known Subclasses:
Call, Invoke, Multi, Transfer

public abstract class ATransaction extends ARecord
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

    • origin

      protected final Address origin
    • sequence

      protected final long sequence
  • Constructor Details

    • ATransaction

      protected ATransaction(long count, Address origin, 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: ARecord
      Writes the raw fields of this record in declared order
      Overrides:
      encodeRaw in class ARecord
      Parameters:
      bs - Array to write to
      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 highly likely to contain the entire object when encoded, including the tag byte. Should not traverse soft Refs, i.e. must be usable on arbitrary partial data structures
      Specified by:
      estimatedEncodingSize in interface IWriteable
      Overrides:
      estimatedEncodingSize in class ARecord
      Returns:
      The estimated size for the binary representation of this object.
    • apply

      public abstract Context 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
    • getOrigin

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

      public final long getSequence()
      Gets the sequence number for this transaction
      Returns:
      Sequence number
    • isCVMValue

      public final boolean isCVMValue()
      Description copied from class: ACell
      Returns true if this Cell represents a first class CVM Value. Sub-structural cells that are not themselves first class values should return false, pretty much everything else should return true. Note: CVM values might not be in a canonical format, e.g. temporary data structures
      Overrides:
      isCVMValue in class ARecord
      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 ARecord
      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.
    • withOrigin

      public abstract ATransaction withOrigin(Address newAddress)
      Updates this transaction with the specified origin 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 representation for message writing. Non-canonical objects may be used on a temporary internal basis, they must always be converted to canonical representations for external use (e.g. Encoding).
      Overrides:
      isCanonical in class ARecord
      Returns:
      true if the object is in canonical format, false otherwise