mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 23:18:14 +01:00
Merge bitcoin/bitcoin#28503: refactor: Remove WithParams serialization helper, use SER_PARAMS_OPFUNC
99990194ceRemove WithParams serialization helper (MarcoFalke)ffffb4af83scripted-diff: Use ser params operator (MarcoFalke)fae9054793test: Use SER_PARAMS_OPFUNC in serialize_tests.cpp (MarcoFalke) Pull request description: Every serialization parameter struct already has the `SER_PARAMS_OPFUNC`, except for one in the tests. For consistency, and to remove verbose code, convert the test to `SER_PARAMS_OPFUNC`, and use it everywhere, then remove the `WithParams` helper. ACKs for top commit: ajtowns: reACK99990194ceTheCharlatan: Re-ACK99990194ceTree-SHA512: be9cae4225a502486fe8d552aaf4b2cd2904a9f73cce9d931c6b7c757594ff1982fcc2c30d00d012cd12b0a9531fd609f8bcd7c94b811e965ac087eb8a3589d3
This commit is contained in:
@@ -66,7 +66,7 @@ template <typename T, typename P>
|
||||
DataStream Serialize(const T& obj, const P& params)
|
||||
{
|
||||
DataStream ds{};
|
||||
ds << WithParams(params, obj);
|
||||
ds << params(obj);
|
||||
return ds;
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ template <typename T, typename P>
|
||||
T Deserialize(DataStream&& ds, const P& params)
|
||||
{
|
||||
T obj;
|
||||
ds >> WithParams(params, obj);
|
||||
ds >> params(obj);
|
||||
return obj;
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ void DeserializeFromFuzzingInput(FuzzBufferType buffer, T&& obj, const P& params
|
||||
{
|
||||
DataStream ds{buffer};
|
||||
try {
|
||||
ds >> WithParams(params, obj);
|
||||
ds >> params(obj);
|
||||
} catch (const std::ios_base::failure&) {
|
||||
throw invalid_fuzzing_input_exception();
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ template <typename T, typename P>
|
||||
DataStream ds{buffer};
|
||||
T obj;
|
||||
try {
|
||||
ds >> WithParams(params, obj);
|
||||
ds >> params(obj);
|
||||
} catch (const std::ios_base::failure&) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user