Changeset View
Changeset View
Standalone View
Standalone View
src/script/script.h
| Show First 20 Lines • Show All 219 Lines • ▼ Show 20 Lines | class CScriptNum { | ||||
| * integers. The semantics are subtle, though: operands must be in the range | * integers. The semantics are subtle, though: operands must be in the range | ||||
| * [-2^31 +1...2^31 -1], but results may overflow (and are valid as long as | * [-2^31 +1...2^31 -1], but results may overflow (and are valid as long as | ||||
| * they are not used in a subsequent numeric operation). CScriptNum enforces | * they are not used in a subsequent numeric operation). CScriptNum enforces | ||||
| * those semantics by storing results as an int64 and allowing out-of-range | * those semantics by storing results as an int64 and allowing out-of-range | ||||
| * values to be returned as a vector of bytes but throwing an exception if | * values to be returned as a vector of bytes but throwing an exception if | ||||
| * arithmetic is done or the result is interpreted as an integer. | * arithmetic is done or the result is interpreted as an integer. | ||||
| */ | */ | ||||
| public: | public: | ||||
| static constexpr size_t MAXIMUM_ELEMENT_SIZE = 4; | static constexpr size_t MAXIMUM_ELEMENT_SIZE_32_BIT = 4; | ||||
| static constexpr size_t MAXIMUM_ELEMENT_SIZE_64_BIT = 8; | |||||
| explicit CScriptNum(const int64_t &n) { m_value = n; } | explicit CScriptNum(const int64_t &n) { m_value = n; } | ||||
| explicit CScriptNum(const std::vector<uint8_t> &vch, bool fRequireMinimal, | explicit CScriptNum(const std::vector<uint8_t> &vch, bool fRequireMinimal, | ||||
| const size_t nMaxNumSize) { | const size_t nMaxNumSize) { | ||||
| if (vch.size() > nMaxNumSize) { | if (vch.size() > nMaxNumSize) { | ||||
| throw scriptnum_error("script number overflow"); | throw scriptnum_error("script number overflow"); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 319 Lines • Show Last 20 Lines | |||||