Package convex.core.transactions
Class ATransaction
java.lang.Object
convex.core.data.AObject
convex.core.data.ACell
convex.core.transactions.ATransaction
- All Implemented Interfaces:
IValidated
,IWriteable
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 Summary
FieldsFields inherited from class convex.core.data.ACell
cachedRef, EMPTY_ARRAY
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionApplies the functional effect of this transaction to the current state.abstract int
encode(byte[] bs, int pos)
Writes this transaction to a byte array, including the message tagint
encodeRaw(byte[] bs, int pos)
Writes this Cell's encoding to a byte array, excluding the tag byteabstract int
Estimate the encoded data size for this Cell.Gets the *origin* Address for this transactionabstract Long
Gets the max juice allowed for this transactionlong
getType()
Gets the most specific known runtime Type for this Cell.boolean
Returns true if this Cell is in a canonical format for message writing.boolean
Returns true if this object represents a first class CVM Value.Converts this Cell to its canonical version.abstract ATransaction
withAddress(Address newAddress)
Updates this transaction with the specified addressabstract ATransaction
withSequence(long newSequence)
Updates this transaction with the specified sequence numberMethods inherited from class convex.core.data.ACell
announce, announce, attachMemorySize, attachRef, cachedEncoding, cachedHash, calcMemorySize, createAnnounced, createEncoding, createPersisted, createPersisted, createRef, equals, equals, getChildRefs, getEncoding, getEncodingLength, getHash, getMemorySize, getRef, getRef, getRefCount, getTag, hashCode, isEmbedded, toString, updateRefs, validate, validateCell, write
Methods inherited from class convex.core.data.AObject
attachEncoding, print, print
-
Field Details
-
address
-
sequence
protected final long sequence
-
-
Constructor Details
-
ATransaction
-
-
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 interfaceIWriteable
- Specified by:
encode
in classACell
- Parameters:
bs
- A byte array to which to write the encodingpos
- 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 -
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
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
Gets the *origin* Address for this transaction- Returns:
- Address for this Transaction
-
getSequence
public final long getSequence() -
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 classACell
- Returns:
- true if the object is a CVM Value, false otherwise
-
getType
Description copied from class:ACell
Gets the most specific known runtime Type for this Cell. -
withSequence
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
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 classACell
- Returns:
- true if the object is in canonical format, false otherwise
-
toCanonical
Description copied from class:ACell
Converts this Cell to its canonical version. Returns this if already canonical- Specified by:
toCanonical
in classACell
- Returns:
- Canonical version of Cell
-