use of com.radixdlt.serialization.DeserializeException in project radixdlt by radixdlt.
the class VirtualSubstateDeserialization method keyToSubstate.
public Particle keyToSubstate(byte typeByte, ByteBuffer buf) throws DeserializeException {
var deserializer = byteToDeserializer.get(typeByte);
if (deserializer == null) {
throw new DeserializeException("Unknown byte type: " + typeByte);
}
try {
var key = deserializer.keyDeserializer().deserialize(buf);
var rawSubstate = deserializer.virtualMapper().map(key);
if (buf.hasRemaining()) {
throw new TrailingBytesException("Buffer has " + buf.remaining() + " bytes remaining.");
}
return rawSubstate;
} catch (Exception e) {
throw new SubstateDeserializationException(deserializer.substateClass(), e);
}
}
use of com.radixdlt.serialization.DeserializeException in project radixdlt by radixdlt.
the class CodecBenchmark method jacksonFromBytesTest.
@Benchmark
public void jacksonFromBytesTest(Blackhole bh) {
try {
DummyTestObject newObj = serialization.fromDson(jacksonBytes, DummyTestObject.class);
bh.consume(newObj);
} catch (DeserializeException ex) {
throw new IllegalStateException("While deserializing from DSON", ex);
}
}
use of com.radixdlt.serialization.DeserializeException in project radixdlt by radixdlt.
the class TimestampedECDSASignatures method fromJSON.
public static TimestampedECDSASignatures fromJSON(JSONArray json) throws DeserializeException {
var builder = ImmutableMap.<BFTNode, TimestampedECDSASignature>builder();
for (int i = 0; i < json.length(); i++) {
var signatureJson = json.getJSONObject(i);
try {
var key = ECPublicKey.fromHex(signatureJson.getString("key"));
var bytes = Bytes.fromHexString(signatureJson.getString("signature"));
var signature = REFieldSerialization.deserializeSignature(ByteBuffer.wrap(bytes));
var timestamp = signatureJson.getLong("timestamp");
builder.put(BFTNode.create(key), TimestampedECDSASignature.from(timestamp, signature));
} catch (PublicKeyException e) {
throw new DeserializeException(e.getMessage());
}
}
return new TimestampedECDSASignatures(builder.build());
}
use of com.radixdlt.serialization.DeserializeException in project radixdlt by radixdlt.
the class RecoverableSubstateVirtualShutdown method recover.
@Override
public SubstateOperation recover(Provider<RadixEngine<LedgerAndBFTProof>> radixEngineProvider) {
var radixEngine = radixEngineProvider.get();
var keyBuf = substateId.getVirtualKey().orElseThrow();
Particle substate;
try {
substate = radixEngine.getVirtualSubstateDeserialization().keyToSubstate(typeByte, keyBuf);
} catch (DeserializeException e) {
throw new IllegalStateException("Could not deserialize virtual substate.");
}
return new SubstateOperation(substate, substateId, false);
}
use of com.radixdlt.serialization.DeserializeException 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);
}
}
Aggregations