Package convex.core.transactions
Class Call
- All Implemented Interfaces:
IAssociative<Keyword,
,ACell> IValidated
,IWriteable
,Map<Keyword,
ACell>
Transaction representing a Call to an Actor.
The signer of the transaction will be both the *origin* and *caller* for the Actor code.
This is the most efficient way to execute Actor code directly as a client, and is roughly equivalent to invoking
(call actor offer (function-name arg1 arg2 .....))
-
Nested Class Summary
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Symbol
protected final long
protected final Address
Fields inherited from class convex.core.transactions.ATransaction
origin, sequence
Fields inherited from class convex.core.data.ARecord
DEFAULT_VALUE
Fields inherited from class convex.core.data.ADataStructure
count
Fields 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 Call
create
(Address address, long sequence, Address target, long offer, Symbol functionName, AVector<ACell> args) static Call
int
encode
(byte[] bs, int pos) Writes this transaction to a byte array, including the message tagint
encodeRaw
(byte[] bs, int pos) Writes the raw fields of this record in declared orderint
Estimate the encoded data size for this Cell.Gets the record field content for a given key, or null if not found.Gets the RecordFormat instance that describes this Record's layoutGets the max juice allowed for this transactiongetRef
(int i) Gets a numbered child Ref from within this Cell.int
Gets the number of Refs contained within this Cell.byte
getTag()
Gets the tag byte for this record type.static Call
static Call
read
(ByteBuffer bb) updateRefs
(IRefFunction func) Updates all Refs in this object using the given function.void
Validates the local structure and invariants of this cell.withOrigin
(Address newAddress) Updates this transaction with the specified origin addresswithSequence
(long newSequence) Updates this transaction with the specified sequence numberMethods inherited from class convex.core.transactions.ATransaction
getOrigin, getSequence, getType, isCanonical, isCVMValue
Methods inherited from class convex.core.data.ARecord
accumulateEntrySet, accumulateKeySet, accumulateValues, assoc, assocEntry, containsKey, containsValue, dissoc, dissoc, empty, entryAt, entrySet, forEach, get, getEntry, getEntryByHash, getKeyRefEntry, getKeys, getValuesArray, keySet, reduceEntries, reduceValues, toCanonical, toHashMap, values
Methods inherited from class convex.core.data.AMap
clear, conj, containsKey, containsKeyRef, containsValue, entryVector, filterValues, get, get, getElementRef, merge, print, put, putAll, remove, slice, slice
Methods inherited from class convex.core.data.ADataStructure
conjAll, count, isEmpty, size, toCVMString
Methods inherited from class convex.core.data.ACell
announce, announce, attachMemorySize, attachRef, cachedEncoding, cachedHash, calcMemorySize, createAnnounced, createEncoding, createPersisted, createPersisted, createRef, equals, equals, getCanonical, getChildRefs, getEncoding, getEncodingLength, getHash, getMemorySize, getRef, hashCode, isCompletelyEncoded, isEmbedded, mark, mark, toString, validate, write
Methods inherited from class convex.core.data.AObject
attachEncoding, print, print
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, getOrDefault, hashCode, isEmpty, merge, putIfAbsent, remove, replace, replace, replaceAll, size
-
Field Details
-
target
-
offer
protected final long offer -
functionName
-
args
-
-
Constructor Details
-
Call
-
-
Method Details
-
create
-
create
-
encode
public int encode(byte[] bs, int pos) Description copied from class:ATransaction
Writes this transaction to a byte array, including the message tag- Specified by:
encode
in interfaceIWriteable
- Specified by:
encode
in 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:ARecord
Writes the raw fields of this record in declared order- Overrides:
encodeRaw
in classATransaction
- Parameters:
bs
- Array to write topos
- The offset into the byte array- Returns:
- New position after writing
-
read
- Throws:
BadFormatException
-
read
- Throws:
BadFormatException
-
estimatedEncodingSize
public 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 interfaceIWriteable
- Specified by:
estimatedEncodingSize
in classATransaction
- Returns:
- The estimated size for the binary representation of this object.
-
apply
Description copied from class:ATransaction
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)
- Specified by:
apply
in classATransaction
- Parameters:
ctx
- Context for which to apply this Transaction- Returns:
- The updated chain state
-
getMaxJuice
Description copied from class:ATransaction
Gets the max juice allowed for this transaction- Specified by:
getMaxJuice
in classATransaction
- Returns:
- Juice limit
-
validateCell
Description copied from class:ACell
Validates 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:
validateCell
in classACell
- Throws:
InvalidDataException
- If the Cell is invalid
-
getRefCount
public int getRefCount()Description copied from class:ACell
Gets the number of Refs contained within this Cell. This number is final / immutable for any given instance and is defined by the Cell encoding rules. WARNING: may not be valid id Cell is not canonical Contained Refs may be either external or embedded.- Specified by:
getRefCount
in classACell
- Returns:
- The number of Refs in this Cell
-
getRef
Description copied from class:ACell
Gets a numbered child Ref from within this Cell. WARNING: May be unreliable is cell is not canonical -
updateRefs
Description copied from class:ACell
Updates 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. The implementation *should* re-attach any original encoding in order to prevent re-encoding or surplus hashing 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:
updateRefs
in classACell
- Parameters:
func
- Ref update function- Returns:
- Cell with updated Refs
-
withSequence
Description copied from class:ATransaction
Updates this transaction with the specified sequence number- Specified by:
withSequence
in classATransaction
- Parameters:
newSequence
- New sequence number- Returns:
- Updated transaction, or this transaction if the sequence number is unchanged.
-
withOrigin
Description copied from class:ATransaction
Updates this transaction with the specified origin address- Specified by:
withOrigin
in classATransaction
- Parameters:
newAddress
- New address- Returns:
- Updated transaction, or this transaction if unchanged.
-
getTag
public byte getTag()Description copied from class:ARecord
Gets the tag byte for this record type. The Tag is the byte used to identify the record in the binary encoding. -
get
Description copied from class:ARecord
Gets the record field content for a given key, or null if not found. -
getFormat
Description copied from class:ARecord
Gets the RecordFormat instance that describes this Record's layout
-