HomePhabricator

Add a generic approach for (de)serialization of objects using code in other…

Description

Add a generic approach for (de)serialization of objects using code in other classes

Summary:
PR description:

This introduces a const-correct generic approach for serializing objects using custom
serializers (defined separately from the object being serialized), then converts VARINT
to use that approach, and then converts chain.h to the new framework (including
the new const-correct VARINT macro).

Commit message:

This adds the (internal) Wrapper class, and the Using function that uses it. Given
a class F that implements Ser(stream, const object&) and Unser(stream, object&)
functions, this permits writing e.g. READWRITE(Using<F>(object)).

This is a backport of Core PR17896 [1/3]
https://github.com/bitcoin/bitcoin/pull/17896/commits/ca62563df341786d1d1809a037d8b592924e78c4

Test Plan: ninja

Reviewers: #bitcoin_abc, majcosta

Reviewed By: #bitcoin_abc, majcosta

Differential Revision: https://reviews.bitcoinabc.org/D8626

Details

Provenance
Pieter Wuille <pieter.wuille@gmail.com>Authored on Jan 8 2020, 16:56
PiRKCommitted on Dec 8 2020, 19:38
PiRKPushed on Dec 8 2020, 19:38
Reviewer
Restricted Project
Differential Revision
D8626: Add a generic approach for (de)serialization of objects using code in other classes
Parents
rABC978dc6c00a22: Work around GCC -Wmaybe-uninitialized false positive
Branches
Unknown
Tags
Unknown