Skip to content

Instantly share code, notes, and snippets.

@lightclient
Last active January 22, 2021 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lightclient/9e7497e2b5a05427d87e7e662442e2c5 to your computer and use it in GitHub Desktop.
Save lightclient/9e7497e2b5a05427d87e7e662442e2c5 to your computer and use it in GitHub Desktop.
DIFFICULTY + BLOCKHASH tracer
{
hist: {
DIFFICULTY: {},
BLOCKHASH: {},
CALLCODE: {},
},
found: false,
fault: function(log) {},
step: function(log) {
var op = log.op.toString();
var addr = toHex(log.contract.getAddress());
if(op == "DIFFICULTY" || op == "BLOCKHASH" || op == "CALLCODE") {
if(this.hist[op][addr]) {
this.hist[op][addr]++;
} else {
this.hist[op][addr] = 1;
} this.found = true;
}
},
result: function() {
if (this.found) {
return this.hist;
} else {
return ""
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment