Drop the util::u160 type

This commit is contained in:
Alex Beregszaszi 2020-12-04 18:59:36 +00:00
parent 37be1b3ed9
commit ac192ff4c1
4 changed files with 1 additions and 19 deletions

View File

@ -65,7 +65,6 @@ using bytesConstRef = util::vector_ref<uint8_t const>;
using bigint = boost::multiprecision::number<boost::multiprecision::cpp_int_backend<>>;
using u256 = boost::multiprecision::number<boost::multiprecision::cpp_int_backend<256, 256, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void>>;
using s256 = boost::multiprecision::number<boost::multiprecision::cpp_int_backend<256, 256, boost::multiprecision::signed_magnitude, boost::multiprecision::unchecked, void>>;
using u160 = boost::multiprecision::number<boost::multiprecision::cpp_int_backend<160, 160, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void>>;
// Map types.
using StringMap = std::map<std::string, std::string>;

View File

@ -373,7 +373,7 @@ inline void toBigEndian(T _val, Out& o_out)
/// Converts a big-endian byte-stream represented on a templated collection to a templated integer value.
/// @a In will typically be either std::string or bytes.
/// @a T will typically by unsigned, u160, u256 or bigint.
/// @a T will typically by unsigned, u256 or bigint.
template <class T, class In>
inline T fromBigEndian(In const& _bytes)
{
@ -383,7 +383,6 @@ inline T fromBigEndian(In const& _bytes)
return ret;
}
inline bytes toBigEndian(u256 _val) { bytes ret(32); toBigEndian(_val, ret); return ret; }
inline bytes toBigEndian(u160 _val) { bytes ret(20); toBigEndian(_val, ret); return ret; }
/// Convenience function for toBigEndian.
/// @returns a byte array just big enough to represent @a _val.

View File

@ -173,12 +173,6 @@ BOOST_AUTO_TEST_CASE(converting_constructor)
BOOST_AUTO_TEST_CASE(arith_constructor)
{
FixedHash<20> a(u160(0x1234));
BOOST_CHECK_EQUAL(
a.hex(),
"0000000000000000000000000000000000001234"
);
FixedHash<32> b(u256(0x12340000));
BOOST_CHECK_EQUAL(
b.hex(),
@ -190,9 +184,6 @@ BOOST_AUTO_TEST_CASE(arith_constructor)
BOOST_AUTO_TEST_CASE(to_arith)
{
FixedHash<20> a{};
BOOST_CHECK_EQUAL(u160(a), 0);
FixedHash<32> b("c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470");
BOOST_CHECK_EQUAL(u256(b), u256("0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"));
}

View File

@ -125,12 +125,6 @@ BOOST_AUTO_TEST_CASE(test_format_number_readable)
BOOST_CHECK_EQUAL(formatNumberReadable(u256(0x100000000)), "2**32");
BOOST_CHECK_EQUAL(formatNumberReadable(u256(0xFFFFffff)), "2**32 - 1");
u160 a = 0;
for (int i = 0; i < 20; i++)
{
a <<= 8;
a |= 0x55;
}
u256 b = 0;
for (int i = 0; i < 32; i++)
{
@ -144,7 +138,6 @@ BOOST_AUTO_TEST_CASE(test_format_number_readable)
u256(0xFFFFffffFFFFffff) << 128 |
u256(0xFFFFffffFFFFffff) << 64 |
u256(0xFFFFffffFFFFffff);
BOOST_CHECK_EQUAL(formatNumberReadable(a, true), "0x5555...{+32 more}...5555");
BOOST_CHECK_EQUAL(formatNumberReadable(b, true), "0x5555...{+56 more}...5555");
BOOST_CHECK_EQUAL(formatNumberReadable(c, true), "0xABCD...{+56 more}...6789");
BOOST_CHECK_EQUAL(formatNumberReadable(d, true), "0xAAAAaaaaAAAAaaab * 2**192 - 1");