mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-23 07:15:29 +01:00
serialization: Reverse ParamsStream constructor order
Move parameter argument after stream argument so will be possible to accept multiple variadic parameter arguments in the following commit. Also reverse template parameter order for consistency.
This commit is contained in:
parent
83436d14f0
commit
cb28849a88
3 changed files with 7 additions and 7 deletions
|
@ -171,7 +171,7 @@ void AddrManImpl::Serialize(Stream& s_) const
|
|||
*/
|
||||
|
||||
// Always serialize in the latest version (FILE_FORMAT).
|
||||
ParamsStream s{CAddress::V2_DISK, s_};
|
||||
ParamsStream s{s_, CAddress::V2_DISK};
|
||||
|
||||
s << static_cast<uint8_t>(FILE_FORMAT);
|
||||
|
||||
|
@ -236,7 +236,7 @@ void AddrManImpl::Unserialize(Stream& s_)
|
|||
s_ >> Using<CustomUintFormatter<1>>(format);
|
||||
|
||||
const auto ser_params = (format >= Format::V3_BIP155 ? CAddress::V2_DISK : CAddress::V1_DISK);
|
||||
ParamsStream s{ser_params, s_};
|
||||
ParamsStream s{s_, ser_params};
|
||||
|
||||
uint8_t compat;
|
||||
s >> compat;
|
||||
|
|
|
@ -199,7 +199,7 @@ static std::vector<CAddress> ConvertSeeds(const std::vector<uint8_t> &vSeedsIn)
|
|||
std::vector<CAddress> vSeedsOut;
|
||||
FastRandomContext rng;
|
||||
DataStream underlying_stream{vSeedsIn};
|
||||
ParamsStream s{CAddress::V2_NETWORK, underlying_stream};
|
||||
ParamsStream s{underlying_stream, CAddress::V2_NETWORK};
|
||||
while (!s.eof()) {
|
||||
CService endpoint;
|
||||
s >> endpoint;
|
||||
|
|
|
@ -1104,14 +1104,14 @@ size_t GetSerializeSize(const T& t)
|
|||
}
|
||||
|
||||
/** Wrapper that overrides the GetParams() function of a stream. */
|
||||
template <typename Params, typename SubStream>
|
||||
template <typename SubStream, typename Params>
|
||||
class ParamsStream
|
||||
{
|
||||
const Params& m_params;
|
||||
SubStream& m_substream;
|
||||
|
||||
public:
|
||||
ParamsStream(const Params& params LIFETIMEBOUND, SubStream& substream LIFETIMEBOUND) : m_params{params}, m_substream{substream} {}
|
||||
ParamsStream(SubStream& substream LIFETIMEBOUND, const Params& params LIFETIMEBOUND) : m_params{params}, m_substream{substream} {}
|
||||
template <typename U> ParamsStream& operator<<(const U& obj) { ::Serialize(*this, obj); return *this; }
|
||||
template <typename U> ParamsStream& operator>>(U&& obj) { ::Unserialize(*this, obj); return *this; }
|
||||
void write(Span<const std::byte> src) { m_substream.write(src); }
|
||||
|
@ -1145,13 +1145,13 @@ public:
|
|||
template <typename Stream>
|
||||
void Serialize(Stream& s) const
|
||||
{
|
||||
ParamsStream ss{m_params, s};
|
||||
ParamsStream ss{s, m_params};
|
||||
::Serialize(ss, m_object);
|
||||
}
|
||||
template <typename Stream>
|
||||
void Unserialize(Stream& s)
|
||||
{
|
||||
ParamsStream ss{m_params, s};
|
||||
ParamsStream ss{s, m_params};
|
||||
::Unserialize(ss, m_object);
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue