bitcoinjs-lib icon indicating copy to clipboard operation
bitcoinjs-lib copied to clipboard

perfs: optimize script.decomplie return type

Open jasonandjay opened this issue 9 months ago • 3 comments

Optimize script.decomplie return type to Stack

  1. avoid type error. for example: null.map https://github.com/bitcoinjs/bitcoinjs-lib/issues/2096
  2. avoid unnecessary type assertion
  3. simplify the judgment of returned results

jasonandjay avatar May 10 '24 04:05 jasonandjay

There is a semantic difference between [] and null

null indicates "the decompilation failed / there is no valid decompilation that exists for this Buffer" without need for throwing an exception.

[] means "we decompiled it and it was an empty script."

By collapsing this, [] can now mean two things.

This is a breaking change.

I agree that the bug in the other issue should be fixed, but this is not the way we should fix it.

Thanks for the PR though.

junderw avatar May 10 '24 04:05 junderw

There is a semantic difference between [] and null

null indicates "the decompilation failed / there is no valid decompilation that exists for this Buffer" without need for throwing an exception.

[] means "we decompiled it and it was an empty script."

By collapsing this, [] can now mean two things.

This is a breaking change.

I agree that the bug in the other issue should be fixed, but this is not the way we should fix it.

Thanks for the PR though.

I agree

How about throw error replace return null ?

jasonandjay avatar May 10 '24 06:05 jasonandjay

I'd rather not have to think about the knock on effects.

A simple bug fix is easier to approve.

junderw avatar May 10 '24 06:05 junderw

@junderw how about this? just throw an error from toASM when decompile failed Minimal impact on existing logic

jasonandjay avatar May 17 '24 03:05 jasonandjay

Please help reRun actions it`s failed for netowrk issue, reRun failed works will repair

jasonandjay avatar May 17 '24 07:05 jasonandjay