Page MenuHomePhabricator

Pull minimal check out of CScriptNum constr. into IsMinimalArray
ClosedPublic

Authored by schancel on Mar 18 2018, 08:59.

Details

Summary

Move the check for minimal encoded arrays out of CScriptNum's
constructor and into a free function. This enables it to be used
elsewhere, and avoid hitting exceptions.

Test Plan

make check

Diff Detail

Repository
rABC Bitcoin ABC
Branch
minimalarray
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 2166
Build 2476: Bitcoin ABC Buildbot (legacy)
Build 2475: arc lint + arc unit

Event Timeline

shadders added inline comments.
src/script/script.h
190 ↗(On Diff #3282)

nit: Most constants in this file are declared at the top and use uppercase. Should follow the style as this constant can also be referenced in Num2Bin as a pre-check to ensure the input value is <= 4 bytes. Suggest placing it under:

static const int MAX_SCRIPT_SIZE = 10000;

static const int DEFAUL_MAX_NUM_BYTES = 4;

jasonbcox requested changes to this revision.Mar 18 2018, 15:31
jasonbcox added inline comments.
src/script/script.h
190 ↗(On Diff #3282)

+1

This revision now requires changes to proceed.Mar 18 2018, 15:31
This revision is now accepted and ready to land.Mar 18 2018, 18:32
This revision was automatically updated to reflect the committed changes.
src/script/script.h
35 ↗(On Diff #3291)

This belong is CScriptNum like it was before. The name DEFAULT_MAX_NUM_BYTES has no meaning without context, which is why you added a comment to begin with.

194 ↗(On Diff #3291)

Same thing, IsMinimalArray has no meaning outside of CScriptNum. Having it as a member called IsMinimalEncoding or something would be more appropriate.