Package convex.core

Class BlockResult

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

public class BlockResult extends ARecord
Class representing the result of applying a Block to a State. Each transaction in the block has a corresponding result entry, which may either be a valid result or an error.
  • Method Details

    • create

      public static BlockResult create(State state, Result[] results)
      Create a BlockResult
      Parameters:
      state - Resulting State
      results - Results of transactions in Block
      Returns:
      BlockResult instance
    • create

      public static BlockResult create(State state, AVector<Result> results)
      Create a BlockResult
      Parameters:
      state - Resulting State
      results - Results of transactions in Block
      Returns:
      BlockResult instance
    • getState

      public State getState()
      Get the State resulting from this Block.
      Returns:
      State after Block is executed
    • getResults

      public AVector<Result> getResults()
      Gets the Results of all transactions in the Block
      Returns:
      Vector of Results
    • isError

      public boolean isError(long i)
      Checks if a result at a specific position is an error
      Parameters:
      i - Index of result in block
      Returns:
      True if result at index i is an error, false otherwise.
    • getResult

      public Result getResult(long i)
      Gets a specific Result
      Parameters:
      i - Index of Result
      Returns:
      Result at specified index for the current Block
    • getErrorCode

      public Object getErrorCode(long i)
      Gets the error code for a given transaction
      Parameters:
      i - Index of Result
      Returns:
      Error code, or null if the transaction succeeded.
    • get

      public ACell get(ACell key)
      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:
      key - Key to look up in this record
      Returns:
      Field value for the given key
    • 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
    • updateAll

      protected BlockResult updateAll(ACell[] newVals)
      Description copied from class: ARecord
      Updates all values in this record, in declared field order. Returns this if all values are identical.
      Specified by:
      updateAll in class ARecord
      Parameters:
      newVals - New values to replace current
      Returns:
      Updated Record
    • 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
    • validate

      public void validate() throws InvalidDataException
      Description copied from interface: IValidated
      Validates the complete structure of this object. It is necessary to ensure all child Refs are validated, so the general contract for validate is:
      1. Call super.validate() - which will indirectly call validateCell()
      2. Call validate() on any contained cells in this class
      Specified by:
      validate in interface IValidated
      Overrides:
      validate in class ACell
      Throws:
      InvalidDataException - If the data Valie is invalid in any way
    • 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
      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: ARecord
      Writes the raw fields of this record in declared order
      Overrides:
      encodeRaw in class ARecord
      Parameters:
      bs - Array to write to
      pos - The offset into the byte array
      Returns:
      New position after writing
    • 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 likely to contain the entire object when represented in binary format, including the tag byte.
      Specified by:
      estimatedEncodingSize in interface IWriteable
      Overrides:
      estimatedEncodingSize in class ARecord
      Returns:
      The estimated size for the binary representation of this object.
    • read

      public static BlockResult read(ByteBuffer bb) throws BadFormatException
      Decodes a BlockResult from a ByteBuffer
      Parameters:
      bb - ByteBuffer to read from
      Returns:
      BlockResult instance
      Throws:
      BadFormatException - If encoding format has errors
    • equals

      public boolean equals(AMap<Keyword,​ACell> a)
      Description copied from class: AMap
      Checks this map for equality with another map. In general, maps should be considered equal if they have the same canonical representation, i.e. the same hash value. Subclasses may override this this they have a more efficient equals implementation or a more specific definition of equality.
      Specified by:
      equals in class AMap<Keyword,​ACell>
      Parameters:
      a - Map to compare with
      Returns:
      true if maps are equal, false otherwise.
    • equals

      public boolean equals(BlockResult a)
      Tests if this BlockResult is equal to another
      Parameters:
      a - BlockResult to compare with
      Returns:
      true if equal, false otherwise