Package convex.core.transactions
Class Invoke
java.lang.Object
convex.core.data.AObject
convex.core.data.ACell
convex.core.transactions.ATransaction
convex.core.transactions.Invoke
- All Implemented Interfaces:
IValidated,IWriteable
Transaction class representing the Invoke of an on-chain operation.
The command provided may be specified as either:
- A Form (will be compiled and executed)
- A pre-compiled Op (will be executed directly, cheaper)
-
Field Summary
FieldsFields inherited from class convex.core.transactions.ATransaction
address, sequenceFields 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.static Invokestatic InvokeCreates an Invoke transactionintencode(byte[] bs, int pos)Writes this transaction to a byte array, including the message tagintencodeRaw(byte[] bs, int pos)Writes this Cell's encoding to a byte array, excluding the tag byteintEstimate the encoded data size for this Cell.Get the command for this transaction, as code.Gets the max juice allowed for this transactiongetRef(int i)Gets a numbered child Ref from within this Cell.intGets the number of Refs contained within this Cell.bytegetTag()Gets the tag byte for this cell.booleanReturns true if this Cell is in a canonical format for message writing.voidprint(StringBuilder sb)Prints this Object to a readable String Representationstatic Invokeread(ByteBuffer bb)Read a Transfer transaction from a ByteBufferupdateRefs(IRefFunction func)Updates all Refs in this object using the given function.voidValidates the local structure and invariants of this cell.withAddress(Address newAddress)Updates this transaction with the specified addresswithSequence(long newSequence)Updates this transaction with the specified sequence numberMethods inherited from class convex.core.transactions.ATransaction
getAddress, getSequence, getType, isCVMValue, toCanonicalMethods 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, hashCode, isEmbedded, toString, validate, writeMethods inherited from class convex.core.data.AObject
attachEncoding, print
-
Field Details
-
command
-
-
Constructor Details
-
Invoke
-
-
Method Details
-
create
-
create
Creates an Invoke transaction- Parameters:
address- Address of origin Accountsequence- Sequence numbercommand- Command as a string, which will be read as Convex Lisp code- Returns:
- New Invoke transaction instance
-
encode
public int encode(byte[] bs, int pos)Description copied from class:ATransactionWrites this transaction to a byte array, including the message tag- Specified by:
encodein interfaceIWriteable- Specified by:
encodein classATransaction- 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:ACellWrites this Cell's encoding to a byte array, excluding the tag byte- Overrides:
encodeRawin classATransaction- Parameters:
bs- A byte array to which to write the encodingpos- The offset into the byte array- Returns:
- New position after writing
-
getCommand
Get the command for this transaction, as code.- Returns:
- Command object.
-
read
Read a Transfer transaction from a ByteBuffer- Parameters:
bb- ByteBuffer containing the transaction- Returns:
- The Transfer object
- Throws:
BadFormatException- if the data is invalid
-
apply
Description copied from class:ATransactionApplies 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)
- Specified by:
applyin classATransaction- Parameters:
context- Context for which to apply this Transaction- Returns:
- The updated chain state
-
estimatedEncodingSize
public int estimatedEncodingSize()Description copied from interface:IWriteableEstimate 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.- Specified by:
estimatedEncodingSizein interfaceIWriteable- Specified by:
estimatedEncodingSizein classATransaction- Returns:
- The estimated size for the binary representation of this object.
-
isCanonical
public boolean isCanonical()Description copied from class:ACellReturns 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.- Overrides:
isCanonicalin classATransaction- Returns:
- true if the object is in canonical format, false otherwise
-
print
Description copied from class:AObjectPrints this Object to a readable String Representation -
validateCell
Description copied from class:ACellValidates the local structure and invariants of this cell. Called by validate() super implementation. Should validate directly contained data, but should not validate all other structure of this cell. In particular, should not traverse potentially missing child Refs.- Specified by:
validateCellin classACell- Throws:
InvalidDataException- If the Cell is invalid
-
getMaxJuice
Description copied from class:ATransactionGets the max juice allowed for this transaction- Specified by:
getMaxJuicein classATransaction- Returns:
- Juice limit
-
getRefCount
public int getRefCount()Description copied from class:ACellGets the number of Refs contained within this Cell. This number is final / immutable for any given instance. Contained Refs may be either external or embedded.- Specified by:
getRefCountin classACell- Returns:
- The number of Refs in this Cell
-
getRef
Description copied from class:ACellGets a numbered child Ref from within this Cell. -
updateRefs
Description copied from class:ACellUpdates all Refs in this object using the given function. The function *must not* change the hash value of Refs, in order to ensure structural integrity of modified data structures. This is a building block for a very sneaky trick that enables use to do a lot of efficient operations on large trees of smart references. Must return the same object if no Refs are altered.- Overrides:
updateRefsin classACell- Parameters:
func- Ref update function- Returns:
- Cell with updated Refs
-
withSequence
Description copied from class:ATransactionUpdates this transaction with the specified sequence number- Specified by:
withSequencein classATransaction- Parameters:
newSequence- New sequence number- Returns:
- Updated transaction, or this transaction if the sequence number is unchanged.
-
withAddress
Description copied from class:ATransactionUpdates this transaction with the specified address- Specified by:
withAddressin classATransaction- Parameters:
newAddress- New address- Returns:
- Updated transaction, or this transaction if unchanged.
-
getTag
public byte getTag()Description copied from class:ACellGets the tag byte for this cell. The tag byte will be the first byte of the encoding
-