mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-08 10:31:50 -05:00
Remove support for double serialization
This commit is contained in:
parent
fff1cae43a
commit
66545da200
7 changed files with 0 additions and 43 deletions
|
@ -265,7 +265,6 @@ BITCOIN_CORE_H = \
|
|||
util/tokenpipe.h \
|
||||
util/trace.h \
|
||||
util/translation.h \
|
||||
util/types.h \
|
||||
util/ui_change_type.h \
|
||||
util/url.h \
|
||||
util/vector.h \
|
||||
|
|
|
@ -36,11 +36,6 @@ static_assert(std::numeric_limits<double>::is_iec559, "IEEE 754 double assumed")
|
|||
// Example(s): Everywhere :-)
|
||||
static_assert(std::numeric_limits<unsigned char>::digits == 8, "8-bit byte assumed");
|
||||
|
||||
// Assumption: We assume floating-point widths.
|
||||
// Example(s): Type punning in serialization code (ser_{float,double}_to_uint{32,64}).
|
||||
static_assert(sizeof(float) == 4, "32-bit float assumed");
|
||||
static_assert(sizeof(double) == 8, "64-bit double assumed");
|
||||
|
||||
// Assumption: We assume integer widths.
|
||||
// Example(s): GetSizeOfCompactSize and WriteCompactSize in the serialization
|
||||
// code.
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
|
||||
#include <prevector.h>
|
||||
#include <span.h>
|
||||
#include <util/types.h>
|
||||
|
||||
/**
|
||||
* The maximum size of a serialized object in bytes or number of elements
|
||||
|
@ -123,20 +122,6 @@ template<typename Stream> inline uint64_t ser_readdata64(Stream &s)
|
|||
s.read((char*)&obj, 8);
|
||||
return le64toh(obj);
|
||||
}
|
||||
inline uint64_t ser_double_to_uint64(double x)
|
||||
{
|
||||
uint64_t tmp;
|
||||
std::memcpy(&tmp, &x, sizeof(x));
|
||||
static_assert(sizeof(tmp) == sizeof(x), "double and uint64_t assumed to have the same size");
|
||||
return tmp;
|
||||
}
|
||||
inline double ser_uint64_to_double(uint64_t y)
|
||||
{
|
||||
double tmp;
|
||||
std::memcpy(&tmp, &y, sizeof(y));
|
||||
static_assert(sizeof(tmp) == sizeof(y), "double and uint64_t assumed to have the same size");
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
@ -221,8 +206,6 @@ template<typename Stream> inline void Serialize(Stream& s, int32_t a ) { ser_wri
|
|||
template<typename Stream> inline void Serialize(Stream& s, uint32_t a) { ser_writedata32(s, a); }
|
||||
template<typename Stream> inline void Serialize(Stream& s, int64_t a ) { ser_writedata64(s, a); }
|
||||
template<typename Stream> inline void Serialize(Stream& s, uint64_t a) { ser_writedata64(s, a); }
|
||||
template<typename Stream> inline void Serialize(Stream& s, float a ) { static_assert(ALWAYS_FALSE<Stream>, "Not implemented"); }
|
||||
template<typename Stream> inline void Serialize(Stream& s, double a ) { ser_writedata64(s, ser_double_to_uint64(a)); }
|
||||
template<typename Stream, int N> inline void Serialize(Stream& s, const char (&a)[N]) { s.write(a, N); }
|
||||
template<typename Stream, int N> inline void Serialize(Stream& s, const unsigned char (&a)[N]) { s.write(CharCast(a), N); }
|
||||
template<typename Stream> inline void Serialize(Stream& s, const Span<const unsigned char>& span) { s.write(CharCast(span.data()), span.size()); }
|
||||
|
@ -239,8 +222,6 @@ template<typename Stream> inline void Unserialize(Stream& s, int32_t& a ) { a =
|
|||
template<typename Stream> inline void Unserialize(Stream& s, uint32_t& a) { a = ser_readdata32(s); }
|
||||
template<typename Stream> inline void Unserialize(Stream& s, int64_t& a ) { a = ser_readdata64(s); }
|
||||
template<typename Stream> inline void Unserialize(Stream& s, uint64_t& a) { a = ser_readdata64(s); }
|
||||
template<typename Stream> inline void Unserialize(Stream& s, float& a ) { static_assert(ALWAYS_FALSE<Stream>, "Not implemented"); }
|
||||
template<typename Stream> inline void Unserialize(Stream& s, double& a ) { a = ser_uint64_to_double(ser_readdata64(s)); }
|
||||
template<typename Stream, int N> inline void Unserialize(Stream& s, char (&a)[N]) { s.read(a, N); }
|
||||
template<typename Stream, int N> inline void Unserialize(Stream& s, unsigned char (&a)[N]) { s.read(CharCast(a), N); }
|
||||
template<typename Stream> inline void Unserialize(Stream& s, Span<unsigned char>& span) { s.read(CharCast(span.data()), span.size()); }
|
||||
|
|
|
@ -3,15 +3,12 @@
|
|||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <memusage.h>
|
||||
#include <serialize.h>
|
||||
#include <streams.h>
|
||||
#include <test/fuzz/FuzzedDataProvider.h>
|
||||
#include <test/fuzz/fuzz.h>
|
||||
#include <util/serfloat.h>
|
||||
#include <version.h>
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#include <cmath>
|
||||
#include <limits>
|
||||
|
||||
|
|
|
@ -513,7 +513,6 @@ void WriteToStream(FuzzedDataProvider& fuzzed_data_provider, Stream& stream) noe
|
|||
WRITE_TO_STREAM_CASE(uint32_t, fuzzed_data_provider.ConsumeIntegral<uint32_t>()),
|
||||
WRITE_TO_STREAM_CASE(int64_t, fuzzed_data_provider.ConsumeIntegral<int64_t>()),
|
||||
WRITE_TO_STREAM_CASE(uint64_t, fuzzed_data_provider.ConsumeIntegral<uint64_t>()),
|
||||
WRITE_TO_STREAM_CASE(double, fuzzed_data_provider.ConsumeFloatingPoint<double>()),
|
||||
WRITE_TO_STREAM_CASE(std::string, fuzzed_data_provider.ConsumeRandomLengthString(32)),
|
||||
WRITE_TO_STREAM_CASE(std::vector<char>, ConsumeRandomLengthIntegralVector<char>(fuzzed_data_provider)));
|
||||
} catch (const std::ios_base::failure&) {
|
||||
|
@ -544,7 +543,6 @@ void ReadFromStream(FuzzedDataProvider& fuzzed_data_provider, Stream& stream) no
|
|||
READ_FROM_STREAM_CASE(uint32_t),
|
||||
READ_FROM_STREAM_CASE(int64_t),
|
||||
READ_FROM_STREAM_CASE(uint64_t),
|
||||
READ_FROM_STREAM_CASE(double),
|
||||
READ_FROM_STREAM_CASE(std::string),
|
||||
READ_FROM_STREAM_CASE(std::vector<char>));
|
||||
} catch (const std::ios_base::failure&) {
|
||||
|
|
|
@ -70,7 +70,6 @@ BOOST_AUTO_TEST_CASE(sizes)
|
|||
BOOST_CHECK_EQUAL(sizeof(uint32_t), GetSerializeSize(uint32_t(0), 0));
|
||||
BOOST_CHECK_EQUAL(sizeof(int64_t), GetSerializeSize(int64_t(0), 0));
|
||||
BOOST_CHECK_EQUAL(sizeof(uint64_t), GetSerializeSize(uint64_t(0), 0));
|
||||
BOOST_CHECK_EQUAL(sizeof(double), GetSerializeSize(double(0), 0));
|
||||
// Bool is serialized as char
|
||||
BOOST_CHECK_EQUAL(sizeof(char), GetSerializeSize(bool(0), 0));
|
||||
|
||||
|
@ -84,7 +83,6 @@ BOOST_AUTO_TEST_CASE(sizes)
|
|||
BOOST_CHECK_EQUAL(GetSerializeSize(uint32_t(0), 0), 4U);
|
||||
BOOST_CHECK_EQUAL(GetSerializeSize(int64_t(0), 0), 8U);
|
||||
BOOST_CHECK_EQUAL(GetSerializeSize(uint64_t(0), 0), 8U);
|
||||
BOOST_CHECK_EQUAL(GetSerializeSize(double(0), 0), 8U);
|
||||
BOOST_CHECK_EQUAL(GetSerializeSize(bool(0), 0), 1U);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
// Copyright (c) 2021 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#ifndef BITCOIN_UTIL_TYPES_H
|
||||
#define BITCOIN_UTIL_TYPES_H
|
||||
|
||||
template <class>
|
||||
inline constexpr bool ALWAYS_FALSE{false};
|
||||
|
||||
#endif // BITCOIN_UTIL_TYPES_H
|
Loading…
Add table
Reference in a new issue