mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #8159 from ethereum/fixedhash-cleanup
Remove some rarely used features of FixedHash
This commit is contained in:
commit
53106011eb
@ -63,9 +63,6 @@ public:
|
||||
/// Convert from the corresponding arithmetic type.
|
||||
FixedHash(Arith const& _arith) { toBigEndian(_arith, m_data); }
|
||||
|
||||
/// Convert from unsigned
|
||||
explicit FixedHash(unsigned _u) { toBigEndian(_u, m_data); }
|
||||
|
||||
/// Explicitly construct, copying from a byte array.
|
||||
explicit FixedHash(bytes const& _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min<unsigned>(_b.size(), N)); else { m_data.fill(0); if (_t != FailIfDifferent) { auto c = std::min<unsigned>(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } }
|
||||
|
||||
@ -78,17 +75,12 @@ public:
|
||||
/// Convert to arithmetic type.
|
||||
operator Arith() const { return fromBigEndian<Arith>(m_data); }
|
||||
|
||||
/// @returns true iff this is the empty hash.
|
||||
explicit operator bool() const { return std::any_of(m_data.begin(), m_data.end(), [](uint8_t _b) { return _b != 0; }); }
|
||||
|
||||
// The obvious comparison operators.
|
||||
bool operator==(FixedHash const& _c) const { return m_data == _c.m_data; }
|
||||
bool operator!=(FixedHash const& _c) const { return m_data != _c.m_data; }
|
||||
/// Required to sort objects of this type or use them as map keys.
|
||||
bool operator<(FixedHash const& _c) const { for (unsigned i = 0; i < N; ++i) if (m_data[i] < _c.m_data[i]) return true; else if (m_data[i] > _c.m_data[i]) return false; return false; }
|
||||
|
||||
FixedHash operator~() const { FixedHash ret; for (unsigned i = 0; i < N; ++i) ret[i] = ~m_data[i]; return ret; }
|
||||
|
||||
/// @returns a particular byte from the hash.
|
||||
uint8_t& operator[](unsigned _i) { return m_data[_i]; }
|
||||
/// @returns a particular byte from the hash.
|
||||
@ -112,12 +104,6 @@ public:
|
||||
/// @returns a copy of the object's data as a byte vector.
|
||||
bytes asBytes() const { return bytes(data(), data() + N); }
|
||||
|
||||
/// @returns a mutable reference to the object's data as an STL array.
|
||||
std::array<uint8_t, N>& asArray() { return m_data; }
|
||||
|
||||
/// @returns a constant reference to the object's data as an STL array.
|
||||
std::array<uint8_t, N> const& asArray() const { return m_data; }
|
||||
|
||||
/// Returns the index of the first bit set to one, or size() * 8 if no bits are set.
|
||||
inline unsigned firstBitSet() const
|
||||
{
|
||||
@ -134,8 +120,6 @@ public:
|
||||
return ret;
|
||||
}
|
||||
|
||||
void clear() { m_data.fill(0); }
|
||||
|
||||
private:
|
||||
std::array<uint8_t, N> m_data; ///< The binary data.
|
||||
};
|
||||
|
@ -159,7 +159,7 @@ BOOST_AUTO_TEST_CASE(reserve)
|
||||
BOOST_REQUIRE(callContractFunctionWithValue("reserve(string)", m_fee + 1, encodeDyn(name[1])) == encodeArgs());
|
||||
BOOST_CHECK(callContractFunction("owner(string)", encodeDyn(name[1])) == encodeArgs(h256(account(0), h256::AlignRight)));
|
||||
BOOST_REQUIRE(callContractFunctionWithValue("reserve(string)", m_fee - 1, encodeDyn(name[2])) == encodeArgs());
|
||||
BOOST_CHECK(callContractFunction("owner(string)", encodeDyn(name[2])) == encodeArgs(h256(0)));
|
||||
BOOST_CHECK(callContractFunction("owner(string)", encodeDyn(name[2])) == encodeArgs(h256{}));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(double_reserve)
|
||||
|
@ -465,7 +465,7 @@ BOOST_AUTO_TEST_CASE(creation)
|
||||
deployWallet(200);
|
||||
BOOST_REQUIRE(callContractFunction("isOwner(address)", h256(m_sender, h256::AlignRight)) == encodeArgs(true));
|
||||
bool v2 = solidity::test::Options::get().useABIEncoderV2;
|
||||
BOOST_REQUIRE(callContractFunction("isOwner(address)", ~h256(m_sender, h256::AlignRight)) == (v2 ? encodeArgs() : encodeArgs(false)));
|
||||
BOOST_REQUIRE(callContractFunction("isOwner(address)", h256(~0)) == (v2 ? encodeArgs() : encodeArgs(false)));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(add_owners)
|
||||
|
@ -60,7 +60,7 @@ void InterpreterState::dumpTraceAndState(ostream& _out) const
|
||||
_out << " " << std::uppercase << std::hex << std::setw(4) << offset << ": " << h256(value).hex() << endl;
|
||||
_out << "Storage dump:" << endl;
|
||||
for (auto const& slot: storage)
|
||||
if (slot.second != h256(0))
|
||||
if (slot.second != h256{})
|
||||
_out << " " << slot.first.hex() << ": " << slot.second.hex() << endl;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user