Package convex.core.transactions
Class Transfer
java.lang.Object
convex.core.data.AObject
convex.core.data.ACell
convex.core.data.ACountable<E>
convex.core.data.ADataStructure<MapEntry<K,V>>
convex.core.data.AMap<Keyword,ACell>
convex.core.data.ARecord
convex.core.transactions.ATransaction
convex.core.transactions.Transfer
- All Implemented Interfaces:
IAssociative<Keyword,,ACell> IValidated,IWriteable,Map<Keyword,ACell>
Transaction class representing a coin Transfer from one account to another
-
Nested Class Summary
-
Field Summary
FieldsFields inherited from class convex.core.transactions.ATransaction
origin, sequenceFields inherited from class convex.core.data.ARecord
DEFAULT_VALUEFields inherited from class convex.core.data.ADataStructure
countFields 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 Transferintencode(byte[] bs, int pos) Writes this transaction to a byte array, including the message tagintencodeRaw(byte[] bs, int pos) Writes the raw fields of this record in declared orderintEstimate the encoded data size for this Cell.Gets the record field content for a given key, or null if not found.longGets the transfer amount for this transaction.Gets the RecordFormat instance that describes this Record's layoutintGets the number of Refs contained within this Cell.bytegetTag()Gets the tag byte for this record type.Gets the target address for this transferstatic ATransactionstatic Transferread(ByteBuffer bb) Read a Transfer transaction from a ByteBuffervoidValidates 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, isCVMValueMethods 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, valuesMethods inherited from class convex.core.data.AMap
clear, conj, containsKey, containsKeyRef, containsValue, entryVector, filterValues, get, get, get, getElementRef, merge, print, put, putAll, remove, slice, sliceMethods inherited from class convex.core.data.ADataStructure
checkIndex, conjAll, count, isEmpty, size, toCVMStringMethods 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, getRef, hashCode, isCompletelyEncoded, isEmbedded, mark, mark, toString, updateRefs, validateMethods inherited from class convex.core.data.AObject
attachEncoding, print, printMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, getOrDefault, hashCode, isEmpty, merge, putIfAbsent, remove, replace, replace, replaceAll, size
-
Field Details
-
TRANSFER_JUICE
public static final long TRANSFER_JUICE- See Also:
-
target
-
amount
protected final long amount
-
-
Constructor Details
-
Transfer
-
-
Method Details
-
create
-
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:ARecordWrites the raw fields of this record in declared order- Overrides:
encodeRawin classATransaction- Parameters:
bs- Array to write topos- The offset into the byte array- Returns:
- New position after writing
-
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
-
read
- Throws:
BadFormatException
-
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:
ctx- 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 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:
estimatedEncodingSizein interfaceIWriteable- Specified by:
estimatedEncodingSizein classATransaction- Returns:
- The estimated size for the binary representation of this object.
-
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
-
getTarget
Gets the target address for this transfer- Returns:
- Address of the destination for this transfer.
-
getAmount
public long getAmount()Gets the transfer amount for this transaction.- Returns:
- Amount of transfer, as a long
-
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 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:
getRefCountin classACell- Returns:
- The number of Refs in this Cell
-
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.
-
withOrigin
Description copied from class:ATransactionUpdates this transaction with the specified origin address- Specified by:
withOriginin classATransaction- Parameters:
newAddress- New address- Returns:
- Updated transaction, or this transaction if unchanged.
-
getTag
public byte getTag()Description copied from class:ARecordGets 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:ARecordGets the record field content for a given key, or null if not found. -
getFormat
Description copied from class:ARecordGets the RecordFormat instance that describes this Record's layout
-