mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-10 05:57:59 +01:00
8d491ae9ecserialization: Add ParamsStream GetStream() method (Ryan Ofsky)951203bcc4net: Simplify ParamsStream usage (Ryan Ofsky)e6794e475cserialization: Accept multiple parameters in ParamsStream constructor (Ryan Ofsky)cb28849a88serialization: Reverse ParamsStream constructor order (Ryan Ofsky)83436d14f0serialization: Drop unnecessary ParamsStream references (Ryan Ofsky)84502b755bserialization: Drop references to GetVersion/GetType (Ryan Ofsky)f3a2b52376serialization: Support for multiple parameters (Ryan Ofsky) Pull request description: Currently it is only possible to attach one serialization parameter to a stream at a time. For example, it is not possible to set a parameter controlling the transaction format and a parameter controlling the address format at the same time because one parameter will override the other. This limitation is inconvenient for multiprocess code since it is not possible to create just one type of stream and serialize any object to it. Instead it is necessary to create different streams for different object types, which requires extra boilerplate and makes using the new parameter fields a lot more awkward than the older version and type fields. Fix this problem by allowing an unlimited number of serialization stream parameters to be set, and allowing them to be requested by type. Later parameters will still override earlier parameters, but only if they have the same type. For an example of different ways multiple parameters can be set, see the new [`with_params_multi`](40f505583f/src/test/serialize_tests.cpp (L394-L410)) unit test. This change requires replacing the `stream.GetParams()` method with a `stream.GetParams<T>()` method in order for serialization code to retrieve the desired parameters. The change is more verbose, but probably a good thing for readability because previously it could be difficult to know what type the `GetParams()` method would return, and now it is more obvious. --- This PR is part of the [process separation project](https://github.com/bitcoin/bitcoin/issues/28722). ACKs for top commit: maflcko: ACK8d491ae9ec🔵 sipa: utACK8d491ae9ecTheCharlatan: ACK8d491ae9ecTree-SHA512: 40b7041ee01c0372b1f86f7fd6f3b6af56ef24a6383f91ffcedd04d388e63407006457bf7ed056b0e37b4dec9ffd5ca006cb8192e488ea2c64678567e38d4647
41 KiB
41 KiB