script tracer: add `op_count` a running opcode count
This commit is contained in:
parent
46bffa304c
commit
4ab69b8a77
|
@ -108,6 +108,7 @@ impl json::ToJson for ScriptError {
|
||||||
#[deriving(PartialEq, Eq, Show, Clone)]
|
#[deriving(PartialEq, Eq, Show, Clone)]
|
||||||
pub struct TraceIteration {
|
pub struct TraceIteration {
|
||||||
index: uint,
|
index: uint,
|
||||||
|
op_count: uint,
|
||||||
opcode: allops::Opcode,
|
opcode: allops::Opcode,
|
||||||
executed: bool,
|
executed: bool,
|
||||||
errored: bool,
|
errored: bool,
|
||||||
|
@ -128,7 +129,7 @@ pub struct ScriptTrace {
|
||||||
pub error: Option<ScriptError>
|
pub error: Option<ScriptError>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl_json!(TraceIteration, index, opcode, executed, errored, effect, stack)
|
impl_json!(TraceIteration, index, opcode, op_count, executed, errored, effect, stack)
|
||||||
|
|
||||||
/// Hashtype of a transaction, encoded in the last byte of a signature,
|
/// Hashtype of a transaction, encoded in the last byte of a signature,
|
||||||
/// specifically in the last 5 bits `byte & 31`
|
/// specifically in the last 5 bits `byte & 31`
|
||||||
|
@ -625,6 +626,7 @@ impl Script {
|
||||||
let mut alt_stack = vec![];
|
let mut alt_stack = vec![];
|
||||||
|
|
||||||
let mut index = 0;
|
let mut index = 0;
|
||||||
|
let mut op_count = 0;
|
||||||
while index < raw.len() {
|
while index < raw.len() {
|
||||||
let executing = exec_stack.iter().all(|e| *e);
|
let executing = exec_stack.iter().all(|e| *e);
|
||||||
let byte = unsafe { *raw.get(index) };
|
let byte = unsafe { *raw.get(index) };
|
||||||
|
@ -637,12 +639,14 @@ impl Script {
|
||||||
opcode: opcode,
|
opcode: opcode,
|
||||||
executed: executing,
|
executed: executing,
|
||||||
errored: true,
|
errored: true,
|
||||||
|
op_count: op_count,
|
||||||
effect: opcode.classify(),
|
effect: opcode.classify(),
|
||||||
stack: vec!["<failed to execute opcode>".to_string()]
|
stack: vec!["<failed to execute opcode>".to_string()]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
None => {}
|
None => {}
|
||||||
}
|
}
|
||||||
|
op_count += 1;
|
||||||
index += 1;
|
index += 1;
|
||||||
// The definitions of all these categories are in opcodes.rs
|
// The definitions of all these categories are in opcodes.rs
|
||||||
//println!("read {} as {} as {} ... stack before op is {}", byte, allops::Opcode::from_u8(byte), allops::Opcode::from_u8(byte).classify(), stack);
|
//println!("read {} as {} as {} ... stack before op is {}", byte, allops::Opcode::from_u8(byte), allops::Opcode::from_u8(byte).classify(), stack);
|
||||||
|
|
Loading…
Reference in New Issue