forked from Qortal/qortal
Check for unknown Qortal-only AT function codes & add safety to AT running in general
This commit is contained in:
parent
faa6405d5f
commit
2c14a12464
@ -100,7 +100,11 @@ public class AT {
|
|||||||
|
|
||||||
// [Re]create AT machine state using AT state data or from scratch as applicable
|
// [Re]create AT machine state using AT state data or from scratch as applicable
|
||||||
MachineState state = MachineState.fromBytes(api, loggerFactory, latestAtStateData.getStateData(), codeBytes);
|
MachineState state = MachineState.fromBytes(api, loggerFactory, latestAtStateData.getStateData(), codeBytes);
|
||||||
|
try {
|
||||||
state.execute();
|
state.execute();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new DataException(String.format("Uncaught exception while running AT '%s'", atAddress), e);
|
||||||
|
}
|
||||||
|
|
||||||
long creation = this.atData.getCreation();
|
long creation = this.atData.getCreation();
|
||||||
byte[] stateData = state.toBytes();
|
byte[] stateData = state.toBytes();
|
||||||
|
@ -449,6 +449,9 @@ public class QortalATAPI extends API {
|
|||||||
public void platformSpecificPostCheckExecute(FunctionData functionData, MachineState state, short rawFunctionCode) throws ExecutionException {
|
public void platformSpecificPostCheckExecute(FunctionData functionData, MachineState state, short rawFunctionCode) throws ExecutionException {
|
||||||
QortalFunctionCode qortalFunctionCode = QortalFunctionCode.valueOf(rawFunctionCode);
|
QortalFunctionCode qortalFunctionCode = QortalFunctionCode.valueOf(rawFunctionCode);
|
||||||
|
|
||||||
|
if (qortalFunctionCode == null)
|
||||||
|
throw new IllegalFunctionCodeException("Unknown Qortal function code 0x" + String.format("%04x", rawFunctionCode) + " encountered");
|
||||||
|
|
||||||
qortalFunctionCode.execute(functionData, state, rawFunctionCode);
|
qortalFunctionCode.execute(functionData, state, rawFunctionCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user