Skip to content

Commit 9999019

Browse files
author
MarcoFalke
committed
Remove WithParams serialization helper
1 parent ffffb4a commit 9999019

File tree

2 files changed

+16
-23
lines changed

2 files changed

+16
-23
lines changed

src/net_processing.cpp

+3-7
Original file line numberDiff line numberDiff line change
@@ -5374,16 +5374,12 @@ void PeerManagerImpl::MaybeSendAddr(CNode& node, Peer& peer, std::chrono::micros
53745374
// No addr messages to send
53755375
if (peer.m_addrs_to_send.empty()) return;
53765376

5377-
const char* msg_type;
5378-
CNetAddr::Encoding ser_enc;
5377+
CNetMsgMaker mm(node.GetCommonVersion());
53795378
if (peer.m_wants_addrv2) {
5380-
msg_type = NetMsgType::ADDRV2;
5381-
ser_enc = CNetAddr::Encoding::V2;
5379+
m_connman.PushMessage(&node, mm.Make(NetMsgType::ADDRV2, CAddress::V2_NETWORK(peer.m_addrs_to_send)));
53825380
} else {
5383-
msg_type = NetMsgType::ADDR;
5384-
ser_enc = CNetAddr::Encoding::V1;
5381+
m_connman.PushMessage(&node, mm.Make(NetMsgType::ADDR, CAddress::V1_NETWORK(peer.m_addrs_to_send)));
53855382
}
5386-
m_connman.PushMessage(&node, CNetMsgMaker(node.GetCommonVersion()).Make(msg_type, WithParams(CAddress::SerParams{{ser_enc}, CAddress::Format::Network}, peer.m_addrs_to_send)));
53875383
peer.m_addrs_to_send.clear();
53885384

53895385
// we only send the big addr message once

src/serialize.h

+13-16
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,11 @@ const Out& AsBase(const In& x)
214214
* }
215215
* };
216216
* which would then be invoked as
217-
* READWRITE(WithParams(BarParameter{...}, Using<FooFormatter>(obj.foo)))
217+
* READWRITE(BarParameter{...}(Using<FooFormatter>(obj.foo)))
218218
*
219219
* parameter(obj) can be invoked anywhere in the call stack; it is
220220
* passed down recursively into all serialization code, until another
221-
* WithParams overrides it.
221+
* serialization parameter overrides it.
222222
*
223223
* Parameters will be implicitly converted where appropriate. This means that
224224
* "parent" serialization code can use a parameter that derives from, or is
@@ -1182,17 +1182,6 @@ class ParamsWrapper
11821182
}
11831183
};
11841184

1185-
/**
1186-
* Return a wrapper around t that (de)serializes it with specified parameter params.
1187-
*
1188-
* See FORMATTER_METHODS_PARAMS for more information on serialization parameters.
1189-
*/
1190-
template <typename Params, typename T>
1191-
static auto WithParams(const Params& params, T&& t)
1192-
{
1193-
return ParamsWrapper<Params, T>{params, t};
1194-
}
1195-
11961185
/**
11971186
* Helper macro for SerParams structs
11981187
*
@@ -1202,8 +1191,16 @@ static auto WithParams(const Params& params, T&& t)
12021191
* constexpr SerParams FOO{....};
12031192
* ss << FOO(obj);
12041193
*/
1205-
#define SER_PARAMS_OPFUNC \
1206-
template <typename T> \
1207-
auto operator()(T&& t) const { return WithParams(*this, t); }
1194+
#define SER_PARAMS_OPFUNC \
1195+
/** \
1196+
* Return a wrapper around t that (de)serializes it with specified parameter params. \
1197+
* \
1198+
* See FORMATTER_METHODS_PARAMS for more information on serialization parameters. \
1199+
*/ \
1200+
template <typename T> \
1201+
auto operator()(T&& t) const \
1202+
{ \
1203+
return ParamsWrapper{*this, t}; \
1204+
}
12081205

12091206
#endif // BITCOIN_SERIALIZE_H

0 commit comments

Comments
 (0)