Browse Source

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.
0.13
Peter Todd 10 years ago
parent
commit
99088d60d8
  1. 7
      src/script/script.h
  2. 2
      src/test/scriptnum_tests.cpp

7
src/script/script.h

@ -195,7 +195,10 @@ public:
m_value = n; 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) { if (vch.size() > nMaxNumSize) {
throw scriptnum_error("script number overflow"); throw scriptnum_error("script number overflow");
@ -318,8 +321,6 @@ public:
return result; return result;
} }
static const size_t nMaxNumSize = 4;
private: private:
static int64_t set_vch(const std::vector<unsigned char>& vch) static int64_t set_vch(const std::vector<unsigned char>& vch)
{ {

2
src/test/scriptnum_tests.cpp

@ -145,7 +145,7 @@ static void RunCreate(const int64_t& num)
{ {
CheckCreateInt(num); CheckCreateInt(num);
CScriptNum scriptnum(num); CScriptNum scriptnum(num);
if (scriptnum.getvch().size() <= CScriptNum::nMaxNumSize) if (scriptnum.getvch().size() <= CScriptNum::nDefaultMaxNumSize)
CheckCreateVch(num); CheckCreateVch(num);
else else
{ {

Loading…
Cancel
Save