Package convex.core
Class BlockResult
java.lang.Object
- All Implemented Interfaces:
IValidated,IWriteable,Map<Keyword,ACell>
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.
-
Nested Class Summary
-
Field Summary
Fields inherited from class convex.core.data.ARecord
DEFAULT_VALUE, formatFields inherited from class convex.core.data.ADataStructure
countFields inherited from class convex.core.data.ACell
cachedRef, EMPTY_ARRAY -
Method Summary
Modifier and TypeMethodDescriptionstatic BlockResultCreate a BlockResultstatic BlockResultCreate a BlockResultintencode(byte[] bs, int pos)Writes this Cell's encoding to a byte array, including a tag byte which will be written firstintencodeRaw(byte[] bs, int pos)Writes the raw fields of this record in declared orderbooleanequals(BlockResult a)Tests if this BlockResult is equal to anotherbooleanChecks this map for equality with another map.intEstimate the encoded data size for this Cell.Gets the record field content for a given key, or null if not found.getErrorCode(long i)Gets the error code for a given transactiongetResult(long i)Gets a specific ResultGets the Results of all transactions in the BlockgetState()Get the State resulting from this Block.bytegetTag()Gets the tag byte for this record type.booleanisError(long i)Checks if a result at a specific position is an errorstatic BlockResultread(ByteBuffer bb)Decodes a BlockResult from a ByteBufferprotected BlockResultUpdates all values in this record, in declared field order.voidvalidate()Validates the complete structure of this object.voidValidates the local structure and invariants of this cell.Methods inherited from class convex.core.data.ARecord
accumulateEntrySet, accumulateKeySet, accumulateValues, assoc, assocEntry, containsKey, containsValue, dissoc, dissoc, empty, entryAt, entrySet, equalsKeys, forEach, get, getEntry, getEntryByHash, getFormat, getKeyRefEntry, getKeys, getRef, getRefCount, getType, getValuesArray, isCanonical, isCVMValue, keySet, print, reduceEntries, reduceValues, toCanonical, toHashMap, updateRefs, valuesMethods inherited from class convex.core.data.AMap
clear, conj, containsKey, containsKeyRef, entryVector, equals, filterValues, get, get, getElementRef, put, putAll, removeMethods inherited from class convex.core.data.ADataStructure
conjAll, count, isEmpty, sizeMethods inherited from class convex.core.data.ACell
announce, announce, attachMemorySize, attachRef, cachedEncoding, cachedHash, calcMemorySize, createAnnounced, createEncoding, createPersisted, createPersisted, createRef, equals, getChildRefs, getEncoding, getEncodingLength, getHash, getMemorySize, getRef, hashCode, isEmbedded, toString, writeMethods inherited from class convex.core.data.AObject
attachEncoding, 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
-
Method Details
-
create
Create a BlockResult- Parameters:
state- Resulting Stateresults- Results of transactions in Block- Returns:
- BlockResult instance
-
create
Create a BlockResult- Parameters:
state- Resulting Stateresults- Results of transactions in Block- Returns:
- BlockResult instance
-
getState
Get the State resulting from this Block.- Returns:
- State after Block is executed
-
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
Gets a specific Result- Parameters:
i- Index of Result- Returns:
- Result at specified index for the current Block
-
getErrorCode
Gets the error code for a given transaction- Parameters:
i- Index of Result- Returns:
- Error code, or null if the transaction succeeded.
-
get
Description copied from class:ARecordGets the record field content for a given key, or null if not found. -
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. -
updateAll
Description copied from class:ARecordUpdates all values in this record, in declared field order. Returns this if all values are identical. -
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
-
validate
Description copied from interface:IValidatedValidates the complete structure of this object. It is necessary to ensure all child Refs are validated, so the general contract for validate is:- Call super.validate() - which will indirectly call validateCell()
- Call validate() on any contained cells in this class
- Specified by:
validatein interfaceIValidated- Overrides:
validatein classACell- Throws:
InvalidDataException- If the data Valie is invalid in any way
-
encode
public int encode(byte[] bs, int pos)Description copied from class:ACellWrites this Cell's encoding to a byte array, including a tag byte which will be written first- Specified by:
encodein interfaceIWriteable- Specified by:
encodein classACell- 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 -
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- Overrides:
estimatedEncodingSizein classARecord- Returns:
- The estimated size for the binary representation of this object.
-
read
Decodes a BlockResult from a ByteBuffer- Parameters:
bb- ByteBuffer to read from- Returns:
- BlockResult instance
- Throws:
BadFormatException- If encoding format has errors
-
equals
Description copied from class:AMapChecks 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. -
equals
Tests if this BlockResult is equal to another- Parameters:
a- BlockResult to compare with- Returns:
- true if equal, false otherwise
-