Skip to content

Commit

Permalink
Make CScriptNum() take nMaxNumSize as an argument
Browse files Browse the repository at this point in the history
While the existing numeric opcodes are all limited to 4-byte bignum
arguments, new opcodes will need different limits.

Rebased-From: 99088d6
  • Loading branch information
petertodd committed Oct 8, 2015
1 parent 71cc9d9 commit 684636b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/script/script.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,10 @@ class CScriptNum
m_value = n;
}

explicit CScriptNum(const std::vector<unsigned char>& vch, bool fRequireMinimal)
static const size_t nDefaultMaxNumSize = 4;

explicit CScriptNum(const std::vector<unsigned char>& vch, bool fRequireMinimal,
const size_t nMaxNumSize = nDefaultMaxNumSize)
{
if (vch.size() > nMaxNumSize) {
throw scriptnum_error("script number overflow");
Expand Down Expand Up @@ -319,8 +322,6 @@ class CScriptNum
return result;
}

static const size_t nMaxNumSize = 4;

private:
static int64_t set_vch(const std::vector<unsigned char>& vch)
{
Expand Down
2 changes: 1 addition & 1 deletion src/test/scriptnum_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ static void RunCreate(const int64_t& num)
{
CheckCreateInt(num);
CScriptNum scriptnum(num);
if (scriptnum.getvch().size() <= CScriptNum::nMaxNumSize)
if (scriptnum.getvch().size() <= CScriptNum::nDefaultMaxNumSize)
CheckCreateVch(num);
else
{
Expand Down

0 comments on commit 684636b

Please sign in to comment.