Search in sources :

Example 1 with REInstructionDataDeserializeException

use of com.radixdlt.engine.parser.exceptions.REInstructionDataDeserializeException in project radixdlt by radixdlt.

the class REInstruction method readFrom.

public static REInstruction readFrom(REParser.ParserState parserState, ByteBuffer buf) throws DeserializeException, REInstructionDataDeserializeException {
    var microOp = REMicroOp.fromByte(buf.get());
    var savedLimit = buf.limit();
    var pos = buf.position();
    try {
        // Set limit
        buf = microOp.lengthType.setNextLimit(buf, microOp.minLength, microOp.maxLength);
        var data = microOp.read(parserState, buf);
        // Sanity check
        if (buf.hasRemaining()) {
            throw new IllegalStateException();
        }
        var length = buf.position() - pos;
        buf.limit(savedLimit);
        return new REInstruction(microOp, data, buf.array(), pos, length);
    } catch (Exception e) {
        throw new REInstructionDataDeserializeException(microOp, e);
    }
}
Also used : REInstructionDataDeserializeException(com.radixdlt.engine.parser.exceptions.REInstructionDataDeserializeException) REInstructionDataDeserializeException(com.radixdlt.engine.parser.exceptions.REInstructionDataDeserializeException) DeserializeException(com.radixdlt.serialization.DeserializeException)

Aggregations

REInstructionDataDeserializeException (com.radixdlt.engine.parser.exceptions.REInstructionDataDeserializeException)1 DeserializeException (com.radixdlt.serialization.DeserializeException)1