From 684636ba67c3eba145a0af8890ed9a7a15deb60a Mon Sep 17 00:00:00 2001 From: Peter Todd Date: Mon, 29 Sep 2014 01:00:01 -0400 Subject: [PATCH] Make CScriptNum() take nMaxNumSize as an argument While the existing numeric opcodes are all limited to 4-byte bignum arguments, new opcodes will need different limits. Rebased-From: 99088d60d8a7747c6d1a7fd5d8cd388be1b3e138 --- src/script/script.h | 7 ++++--- src/test/scriptnum_tests.cpp | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/script/script.h b/src/script/script.h index d5045005b..4a673e5fe 100644 --- a/src/script/script.h +++ b/src/script/script.h @@ -196,7 +196,10 @@ public: m_value = n; } - explicit CScriptNum(const std::vector& vch, bool fRequireMinimal) + static const size_t nDefaultMaxNumSize = 4; + + explicit CScriptNum(const std::vector& vch, bool fRequireMinimal, + const size_t nMaxNumSize = nDefaultMaxNumSize) { if (vch.size() > nMaxNumSize) { throw scriptnum_error("script number overflow"); @@ -319,8 +322,6 @@ public: return result; } - static const size_t nMaxNumSize = 4; - private: static int64_t set_vch(const std::vector& vch) { diff --git a/src/test/scriptnum_tests.cpp b/src/test/scriptnum_tests.cpp index 24c7dd3d5..d95724dbe 100644 --- a/src/test/scriptnum_tests.cpp +++ b/src/test/scriptnum_tests.cpp @@ -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 {