script tracer: Put an obvious "opcode failed" message in the pre-execute stack

This commit is contained in:
Andrew Poelstra 2014-08-25 16:09:00 -07:00
parent 47c346be71
commit 46bffa304c
1 changed files with 8 additions and 5 deletions

View File

@ -110,6 +110,7 @@ pub struct TraceIteration {
index: uint,
opcode: allops::Opcode,
executed: bool,
errored: bool,
effect: opcodes::OpcodeClass,
stack: Vec<String>
}
@ -127,7 +128,7 @@ pub struct ScriptTrace {
pub error: Option<ScriptError>
}
impl_json!(TraceIteration, index, opcode, executed, effect, stack)
impl_json!(TraceIteration, index, opcode, executed, errored, effect, stack)
/// Hashtype of a transaction, encoded in the last byte of a signature,
/// specifically in the last 5 bits `byte & 31`
@ -635,8 +636,9 @@ impl Script {
index: index,
opcode: opcode,
executed: executing,
errored: true,
effect: opcode.classify(),
stack: vec![]
stack: vec!["<failed to execute opcode>".to_string()]
});
}
None => {}
@ -938,9 +940,10 @@ impl Script {
} // end loop
// Store the stack in the trace
trace.as_mut().map(|t|
t.mut_last().map(|t|
t.stack = stack.iter().map(|elem| elem.as_slice().to_hex()).collect()
)
t.mut_last().map(|t| {
t.errored = false;
t.stack = stack.iter().map(|elem| elem.as_slice().to_hex()).collect();
})
);
}
Ok(())