Module convex.core
Package convex.core

Class Receipt

All Implemented Interfaces:
IAssociative<Keyword,ACell>, IValidated, IWriteable, Map<Keyword,ACell>

public class Receipt extends ARecord
Transaction Receipt record. This forms part of the official CVM state transition, so must be correctly computed and encoded
  • Constructor Details

  • Method Details

    • create

      public static Receipt create(ACell result)
    • create

      public static Receipt create(boolean isError, ACell value, AVector<AVector<ACell>> log)
    • createError

      public static Receipt createError(ACell errorCode)
    • get

      public ACell get(Keyword k)
      Description copied from class: ARecord
      Gets the record field content for a given key, or null if not found.
      Specified by:
      get in class ARecord
      Parameters:
      k - Key to look up in this record
      Returns:
      Field value for the given key
    • getErrorCode

      public ACell getErrorCode()
      Gets the error code of this Receipt, or null if not an error
      Returns:
      Error code (probably a Keyword or nil)
    • getResult

      public ACell getResult()
      Gets the result value of this Receipt, or null if an error
      Returns:
      Result from this Receipt
    • 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.
      Specified by:
      getTag in class ARecord
      Returns:
      Record tag byte
    • isCVMValue

      public final boolean isCVMValue()
      Description copied from class: ACell
      Returns true if this cell is a first class CVM Value allowable in the CVM state Sub-structural cells that are not themselves first class values should return false Records and types that are not permissible on the CVM 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
    • getFormat

      public RecordFormat getFormat()
      Description copied from class: ARecord
      Gets the RecordFormat instance that describes this Record's layout
      Specified by:
      getFormat in class ARecord
      Returns:
      RecordFormat instance
    • validateCell

      public void validateCell() throws InvalidDataException
      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 class ACell
      Throws:
      InvalidDataException - If the Cell is invalid
    • equals

      public boolean equals(ACell a)
      Description copied from class: ACell
      Checks for equality with another Cell. In general, Cells are considered equal if they have the same canonical representation, i.e. an identical encoding with the same hash value. Subclasses SHOULD override this if they have a more efficient equals implementation. MUST NOT require reads from Store.
      Specified by:
      equals in class ACell
      Parameters:
      a - Cell to compare with. May be null.
      Returns:
      True if this cell is equal to the other object
    • equals

      public boolean equals(Receipt a)
    • encode

      public int encode(byte[] bs, int pos)
      Description copied from class: ACell
      Writes this Cell's encoding to a byte array, including a tag byte which will be written first. Cell must be canonical, or else an error may occur.
      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: ACell
      Writes this Cell's encoding to a byte array, excluding the tag byte.
      Specified by:
      encodeRaw 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
    • read

      public static Receipt read(byte tag, Blob b, int pos) throws BadFormatException
      Throws:
      BadFormatException
    • updateRefs

      public Receipt updateRefs(IRefFunction func)
      Description copied from class: ACell
      Updates all child Refs in this object using the given function. This clears the currently cached Ref if an update occurred. This is because, presumably, a new Ref for this cell needs to be created. 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 class ACell
      Parameters:
      func - Ref update function
      Returns:
      Cell with updated Refs
    • 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. Contained Refs may be either external or embedded.
      Overrides:
      getRefCount in class ACell
      Returns:
      The number of Refs in this Cell
    • getRef

      public <R extends ACell> Ref<R> getRef(int i)
      Description copied from class: ACell
      Gets a numbered child Ref from within this Cell. WARNING: May need to convert to a canonical instance
      Overrides:
      getRef in class ACell
      Type Parameters:
      R - Type of referenced Cell
      Parameters:
      i - Index of ref to get
      Returns:
      The Ref at the specified index
    • isError

      public boolean isError()