mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 23:07:59 +01:00
Remove WithParams serialization helper
This commit is contained in:
parent
ffffb4af83
commit
99990194ce
2 changed files with 16 additions and 23 deletions
|
@ -5374,16 +5374,12 @@ void PeerManagerImpl::MaybeSendAddr(CNode& node, Peer& peer, std::chrono::micros
|
||||||
// No addr messages to send
|
// No addr messages to send
|
||||||
if (peer.m_addrs_to_send.empty()) return;
|
if (peer.m_addrs_to_send.empty()) return;
|
||||||
|
|
||||||
const char* msg_type;
|
CNetMsgMaker mm(node.GetCommonVersion());
|
||||||
CNetAddr::Encoding ser_enc;
|
|
||||||
if (peer.m_wants_addrv2) {
|
if (peer.m_wants_addrv2) {
|
||||||
msg_type = NetMsgType::ADDRV2;
|
m_connman.PushMessage(&node, mm.Make(NetMsgType::ADDRV2, CAddress::V2_NETWORK(peer.m_addrs_to_send)));
|
||||||
ser_enc = CNetAddr::Encoding::V2;
|
|
||||||
} else {
|
} else {
|
||||||
msg_type = NetMsgType::ADDR;
|
m_connman.PushMessage(&node, mm.Make(NetMsgType::ADDR, CAddress::V1_NETWORK(peer.m_addrs_to_send)));
|
||||||
ser_enc = CNetAddr::Encoding::V1;
|
|
||||||
}
|
}
|
||||||
m_connman.PushMessage(&node, CNetMsgMaker(node.GetCommonVersion()).Make(msg_type, WithParams(CAddress::SerParams{{ser_enc}, CAddress::Format::Network}, peer.m_addrs_to_send)));
|
|
||||||
peer.m_addrs_to_send.clear();
|
peer.m_addrs_to_send.clear();
|
||||||
|
|
||||||
// we only send the big addr message once
|
// we only send the big addr message once
|
||||||
|
|
|
@ -214,11 +214,11 @@ const Out& AsBase(const In& x)
|
||||||
* }
|
* }
|
||||||
* };
|
* };
|
||||||
* which would then be invoked as
|
* which would then be invoked as
|
||||||
* READWRITE(WithParams(BarParameter{...}, Using<FooFormatter>(obj.foo)))
|
* READWRITE(BarParameter{...}(Using<FooFormatter>(obj.foo)))
|
||||||
*
|
*
|
||||||
* parameter(obj) can be invoked anywhere in the call stack; it is
|
* parameter(obj) can be invoked anywhere in the call stack; it is
|
||||||
* passed down recursively into all serialization code, until another
|
* passed down recursively into all serialization code, until another
|
||||||
* WithParams overrides it.
|
* serialization parameter overrides it.
|
||||||
*
|
*
|
||||||
* Parameters will be implicitly converted where appropriate. This means that
|
* Parameters will be implicitly converted where appropriate. This means that
|
||||||
* "parent" serialization code can use a parameter that derives from, or is
|
* "parent" serialization code can use a parameter that derives from, or is
|
||||||
|
@ -1182,17 +1182,6 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Return a wrapper around t that (de)serializes it with specified parameter params.
|
|
||||||
*
|
|
||||||
* See FORMATTER_METHODS_PARAMS for more information on serialization parameters.
|
|
||||||
*/
|
|
||||||
template <typename Params, typename T>
|
|
||||||
static auto WithParams(const Params& params, T&& t)
|
|
||||||
{
|
|
||||||
return ParamsWrapper<Params, T>{params, t};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper macro for SerParams structs
|
* Helper macro for SerParams structs
|
||||||
*
|
*
|
||||||
|
@ -1203,7 +1192,15 @@ static auto WithParams(const Params& params, T&& t)
|
||||||
* ss << FOO(obj);
|
* ss << FOO(obj);
|
||||||
*/
|
*/
|
||||||
#define SER_PARAMS_OPFUNC \
|
#define SER_PARAMS_OPFUNC \
|
||||||
|
/** \
|
||||||
|
* Return a wrapper around t that (de)serializes it with specified parameter params. \
|
||||||
|
* \
|
||||||
|
* See FORMATTER_METHODS_PARAMS for more information on serialization parameters. \
|
||||||
|
*/ \
|
||||||
template <typename T> \
|
template <typename T> \
|
||||||
auto operator()(T&& t) const { return WithParams(*this, t); }
|
auto operator()(T&& t) const \
|
||||||
|
{ \
|
||||||
|
return ParamsWrapper{*this, t}; \
|
||||||
|
}
|
||||||
|
|
||||||
#endif // BITCOIN_SERIALIZE_H
|
#endif // BITCOIN_SERIALIZE_H
|
||||||
|
|
Loading…
Add table
Reference in a new issue