Skip to content

Commit cb28849

Browse files
committed
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.
1 parent 83436d1 commit cb28849

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/addrman.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ void AddrManImpl::Serialize(Stream& s_) const
171171
*/
172172

173173
// Always serialize in the latest version (FILE_FORMAT).
174-
ParamsStream s{CAddress::V2_DISK, s_};
174+
ParamsStream s{s_, CAddress::V2_DISK};
175175

176176
s << static_cast<uint8_t>(FILE_FORMAT);
177177

@@ -236,7 +236,7 @@ void AddrManImpl::Unserialize(Stream& s_)
236236
s_ >> Using<CustomUintFormatter<1>>(format);
237237

238238
const auto ser_params = (format >= Format::V3_BIP155 ? CAddress::V2_DISK : CAddress::V1_DISK);
239-
ParamsStream s{ser_params, s_};
239+
ParamsStream s{s_, ser_params};
240240

241241
uint8_t compat;
242242
s >> compat;

src/net.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ static std::vector<CAddress> ConvertSeeds(const std::vector<uint8_t> &vSeedsIn)
199199
std::vector<CAddress> vSeedsOut;
200200
FastRandomContext rng;
201201
DataStream underlying_stream{vSeedsIn};
202-
ParamsStream s{CAddress::V2_NETWORK, underlying_stream};
202+
ParamsStream s{underlying_stream, CAddress::V2_NETWORK};
203203
while (!s.eof()) {
204204
CService endpoint;
205205
s >> endpoint;

src/serialize.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,14 +1104,14 @@ size_t GetSerializeSize(const T& t)
11041104
}
11051105

11061106
/** Wrapper that overrides the GetParams() function of a stream. */
1107-
template <typename Params, typename SubStream>
1107+
template <typename SubStream, typename Params>
11081108
class ParamsStream
11091109
{
11101110
const Params& m_params;
11111111
SubStream& m_substream;
11121112

11131113
public:
1114-
ParamsStream(const Params& params LIFETIMEBOUND, SubStream& substream LIFETIMEBOUND) : m_params{params}, m_substream{substream} {}
1114+
ParamsStream(SubStream& substream LIFETIMEBOUND, const Params& params LIFETIMEBOUND) : m_params{params}, m_substream{substream} {}
11151115
template <typename U> ParamsStream& operator<<(const U& obj) { ::Serialize(*this, obj); return *this; }
11161116
template <typename U> ParamsStream& operator>>(U&& obj) { ::Unserialize(*this, obj); return *this; }
11171117
void write(Span<const std::byte> src) { m_substream.write(src); }
@@ -1145,13 +1145,13 @@ class ParamsWrapper
11451145
template <typename Stream>
11461146
void Serialize(Stream& s) const
11471147
{
1148-
ParamsStream ss{m_params, s};
1148+
ParamsStream ss{s, m_params};
11491149
::Serialize(ss, m_object);
11501150
}
11511151
template <typename Stream>
11521152
void Unserialize(Stream& s)
11531153
{
1154-
ParamsStream ss{m_params, s};
1154+
ParamsStream ss{s, m_params};
11551155
::Unserialize(ss, m_object);
11561156
}
11571157
};

0 commit comments

Comments
 (0)