Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

txscript: Add exported opcode name to value map. #396

Merged
merged 4 commits into from
Apr 21, 2015

Conversation

davecgh
Copy link
Member

@davecgh davecgh commented Apr 21, 2015

Depends on #395.

This pull request exports a new map named OpcodeByName which can be used to lookup an opcode value given a human-readable opcode name.

It also modifies the test function which does short form parsing to use the new map instead of the internal array.

Closes #267.

davecgh added 4 commits April 21, 2015 13:49
Rather than storing a separate bool for whether or not each flag is set in
every script engine instance, store the flags and check if the relevant
flag is set from each specific location.

This reduces the memory needed by each script engine instance and means
future flags will not require new fields.
This commit modifies the definition of the opcodes to their hex
counterparts rather than decimal since it is far more common to see
scripts in hex.  This makes it easier when manually looking at script
dumps to correlate opcodes.  However, since there are also cases where it
is useful to see the decimal value of the opcode, the decimal value has
been left as a comment.  Obviously converting the numbers is trivial, but
it is handy when looking at the opcode definitions to already have it
there.

In addition, it syncs the opcodes with the latest Bitcoin Core internal
opcodes for completeness and modifies the tests accordingly.
This commit converts the opcode map to an array to improve performance.

Benchmark of executing a standard p2pk transaction:

New: BenchmarkExecute            2000            784349 ns/op
Old: BenchmarkExecute            2000            792600 ns/op

The time is dominated by the signature checking as expected, however there
is still an increase in speed.
This commit exports a new map named OpcodeByName which can be used to
lookup an opcode value given a human-readable opcode name.

It also modifies the test function which does short form parsing to use
the new map instead of the internal array.

Closes btcsuite#267.
@davecgh davecgh force-pushed the txscript_opcodebyname branch from eafd9dd to d66593b Compare April 21, 2015 19:02
@conformal-deploy conformal-deploy merged commit d66593b into btcsuite:master Apr 21, 2015
@davecgh davecgh deleted the txscript_opcodebyname branch April 21, 2015 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[txscript] Feature request: Export parseScript and opcode fields
2 participants