use of org.apache.tuweni.ssz.SSZException in project teku by ConsenSys.
the class TransitionCommand method processStateTransition.
private int processStateTransition(final InAndOutParams params, final StateTransitionFunction transition) {
final Spec spec = params.eth2NetworkOptions.getNetworkConfiguration().getSpec();
try (final InputStream in = selectInputStream(params);
final OutputStream out = selectOutputStream(params)) {
final Bytes inData = Bytes.wrap(ByteStreams.toByteArray(in));
BeaconState state = readState(spec, inData);
try {
BeaconState result = transition.applyTransition(spec, state);
out.write(result.sszSerialize().toArrayUnsafe());
return 0;
} catch (final StateTransitionException | EpochProcessingException | SlotProcessingException e) {
SUB_COMMAND_LOG.error("State transition failed", e);
return 1;
}
} catch (final SSZException e) {
SUB_COMMAND_LOG.error(e.getMessage());
return 1;
} catch (final IOException e) {
SUB_COMMAND_LOG.error("I/O error: " + e.toString());
return 1;
} catch (final Throwable t) {
t.printStackTrace();
return 2;
}
}
Aggregations