Merge bitcoin/bitcoin#28503: refactor: Remove WithParams serialization helper, use SER_PARAMS_OPFUNC

99990194ce Remove WithParams serialization helper (MarcoFalke)
ffffb4af83 scripted-diff: Use ser params operator (MarcoFalke)
fae9054793 test: 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:
    reACK 99990194ce
  TheCharlatan:
    Re-ACK 99990194ce

Tree-SHA512: be9cae4225a502486fe8d552aaf4b2cd2904a9f73cce9d931c6b7c757594ff1982fcc2c30d00d012cd12b0a9531fd609f8bcd7c94b811e965ac087eb8a3589d3
This commit is contained in:
fanquake
2023-10-31 10:51:37 +00:00
7 changed files with 79 additions and 82 deletions

View File

@@ -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();
}

View File

@@ -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;
}