aboutsummaryrefslogtreecommitdiff
path: root/src/serialize.h
AgeCommit message (Collapse)Author
2023-11-16serialize: Drop useless version param from GetSerializeSize()Anthony Towns
2023-11-16serialize: drop GetSerializeSizeManyAnthony Towns
2023-11-16serialize: Drop nVersion from [C]SizeComputerAnthony Towns
Protocol version is no longer needed to work out the serialized size of objects so drop that information from CSizeComputer and rename the class to SizeComputer.
2023-10-30Remove WithParams serialization helperMarcoFalke
2023-10-13scripted-diff: Use ser params operatorMarcoFalke
-BEGIN VERIFY SCRIPT- sed -i 's|WithParams(\([a-zA-Z:._]\+\), |\1(|g' $( git grep -l WithParams ) -END VERIFY SCRIPT-
2023-10-08serialize: make GetSizeOfCompactSize constexprAntoine Poinsot
2023-09-19Remove SER_GETHASH, hard-code client version in CKeyPool serializeMarcoFalke
It was never set, so it can be removed along with any code reading it.
2023-09-15Merge bitcoin/bitcoin#28473: refactor: Serialization parameter cleanupsfanquake
fb6a2ab63e310d8b600352ef41aab6dafccfbff0 scripted-diff: use SER_PARAMS_OPFUNC (Anthony Towns) 5e5c8f86b60a8018e8801fb44bbe56ce97d9deef serialize: add SER_PARAMS_OPFUNC (Anthony Towns) 33203f59b482bddfe0bbe7d497cb8731ce8334a4 serialize: specify type for ParamsWrapper not ref (Anthony Towns) bf147bfffa1afb11721f30e83eec1fa829f64d5f serialize: move ser_action functions out of global namespace (Anthony Towns) Pull request description: Cleanups after #25284: * ser_action namespacing - https://github.com/bitcoin/bitcoin/pull/25284#discussion_r1316189977 * make reference implicit - https://github.com/bitcoin/bitcoin/pull/25284#discussion_r1316277030 * function notation - https://github.com/bitcoin/bitcoin/pull/25284#issuecomment-1710714821 ACKs for top commit: MarcoFalke: lgtm ACK fb6a2ab63e310d8b600352ef41aab6dafccfbff0 💨 TheCharlatan: ACK fb6a2ab63e310d8b600352ef41aab6dafccfbff0 Tree-SHA512: aacca2ee9cfec360ade6b394606e13d1dfe05bc29c5fbdd48a4e6992bd420312d4ed0d32218d95c560646af326e9977728dc2e759990636298e326947f6f9526
2023-09-14serialize: add SER_PARAMS_OPFUNCAnthony Towns
2023-09-14serialize: specify type for ParamsWrapper not refAnthony Towns
2023-09-14serialize: move ser_action functions out of global namespaceAnthony Towns
2023-09-12[refactor] Allow std::array<std::byte, N> in serialize.hMarcoFalke
This is already possible for C-style arrays, so allow it for C++11 std::array as well.
2023-08-28Support for serialization parametersMarcoFalke
The moved part can be reviewed with the git options --ignore-all-space --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space (Modified by Marco Falke) Co-authored-by: Pieter Wuille <pieter@wuille.net>
2023-08-28Rename CSerAction* to Action*MarcoFalke
This allows new code, added in the next commit, to conform to the coding guideline: No C-prefix for class names.
2023-08-28Replace READWRITEAS macro with AsBase wrapping functionMarcoFalke
Co-authored-by: Pieter Wuille <pieter@wuille.net>
2023-08-03refactor: use "if constexpr" in std::vector's Unserialize()Martin Leitner-Ankerl
This gets rid of unnecessarily creating a temporary object T() to call the right function.
2023-08-03refactor: use "if constexpr" in std::vector's Serialize()Martin Leitner-Ankerl
This gets rid of unnecessarily creating a temporary object T() to call the right function.
2023-08-03refactor: use "if constexpr" in prevector's Unserialize()Martin Leitner-Ankerl
This gets rid of unnecessarily creating a temporary object T() to call the right function.
2023-08-03refactor: use "if constexpr" in prevector's Serialize()Martin Leitner-Ankerl
This gets rid of unnecessarily creating a temporary object T() to call the right function.
2023-08-03refactor: use fold expressions instead of recursive calls in UnserializeMany()Martin Leitner-Ankerl
Instead of recursively calling `UnserializeMany` and peeling off one argument at a time, use a fold expression. This simplifies the code, makes it most likely faster because it reduces the number of function calls, and compiles faster because there are fewer template instantiations.
2023-08-03refactor: use fold expressions instead of recursive calls in SerializeMany()Martin Leitner-Ankerl
Instead of recursively calling `SerializeMany` and peeling off one argument at a time, use a fold expression. This simplifies the code, makes it most likely faster because it reduces the number of function calls, and compiles faster because there are fewer template instantiations.
2023-06-30Allow std::byte serializationMarcoFalke
2023-06-29Merge bitcoin/bitcoin#27978: refactor: Drop unsafe AsBytePtr functionAndrew Chow
7c853619ee9ea17a79f1234b6c7871a45ceadcb9 refactor: Drop unsafe AsBytePtr function (Ryan Ofsky) Pull request description: Replace calls to `AsBytePtr` with calls to `AsBytes` or `reinterpret_cast`. `AsBytePtr` is just a wrapper around `reinterpret_cast`. It accepts any type of pointer as an argument and uses `reinterpret_cast` to cast the argument to a `std::byte` pointer. Despite taking any type of pointer as an argument, it is not useful to call `AsBytePtr` on most types of pointers, because byte representations of most types will be platform specific or undefined. Also, because it is named similarly to the `AsBytes` function, `AsBytePtr` looks safer than it actually is. Both `AsBytes` and `AsBytePtr` call reinterpret_cast internally and may be unsafe to use with certain types, but AsBytes at least has some type checking and can only be called on `Span` objects, while `AsBytePtr` can be called on any pointer argument. The change was motivated by discussion on #27973 and #27927 and is compatible with those PRs ACKs for top commit: jonatack: re-ACK 7c853619ee9ea17a79f1234b6c7871a45ceadcb9 sipa: utACK 7c853619ee9ea17a79f1234b6c7871a45ceadcb9 achow101: ACK 7c853619ee9ea17a79f1234b6c7871a45ceadcb9 Tree-SHA512: 200d858b1d4d579f081a7f9a14d488a99713b4918b4564ac3dd5c18578d927dbd6426e62e02f49f04a3fa73ca02ff7109c495cb0b92bec43c27d9b74e2f95757
2023-06-28refactor: Drop unsafe AsBytePtr functionRyan Ofsky
Replace calls to AsBytePtr with direct calls to AsBytes or reinterpret_cast. AsBytePtr is just a wrapper around reinterpret_cast. It accepts any type of pointer as an argument and uses reinterpret_cast to cast the argument to a std::byte pointer. Despite taking any type of pointer as an argument, it is not useful to call AsBytePtr on most types of pointers, because byte representations of most types will be implmentation-specific. Also, because it is named similarly to the AsBytes function, AsBytePtr looks safer than it actually is. Both AsBytes and AsBytePtr call reinterpret_cast internally and may be unsafe to use with certain types, but AsBytes at least has some type checking and can only be called on Span objects, while AsBytePtr can be called on any pointer argument. Co-authored-by: Pieter Wuille <pieter@wuille.net>
2023-06-27util: Allow std::byte and char Span serializationMarcoFalke
2023-01-31clang-tidy: Fix `modernize-use-default-member-init` in headersHennadii Stepanov
See https://clang.llvm.org/extra/clang-tidy/checks/modernize/use-default-member-init.html
2022-12-24scripted-diff: Bump copyright headersHennadii Stepanov
-BEGIN VERIFY SCRIPT- ./contrib/devtools/copyright_header.py update ./ -END VERIFY SCRIPT- Commits of previous years: - 2021: f47dda2c58b5d8d623e0e7ff4e74bc352dfa83d7 - 2020: fa0074e2d82928016a43ca408717154a1c70a4db - 2019: aaaaad6ac95b402fe18d019d67897ced6b316ee0
2022-07-26Add ChronoFormatter to serializeMarcoFalke
2022-04-26scripted-diff: rename BytePtr to AsBytePtrJoão Barbosa
Building with iPhoneOS SDK fails because it also has `BytePtr` defined in /usr/include/MacTypes.h. -BEGIN VERIFY SCRIPT- sed -i 's/BytePtr/AsBytePtr/' $(git grep -l "BytePtr" src) -END VERIFY SCRIPT-
2022-01-02Remove unused char serializeMarcoFalke
2022-01-02Use spans of std::byte in serializeMarcoFalke
This switches .read() and .write() to take spans of bytes.
2021-12-30scripted-diff: Bump copyright headersHennadii Stepanov
-BEGIN VERIFY SCRIPT- ./contrib/devtools/copyright_header.py update ./ -END VERIFY SCRIPT- Commits of previous years: * 2020: fa0074e2d82928016a43ca408717154a1c70a4db * 2019: aaaaad6ac95b402fe18d019d67897ced6b316ee0
2021-12-10Types are compact size uintsAndrew Chow
2021-05-31refactor: Switch serialize to uint8_t (1/n)MarcoFalke
2021-05-24Remove support for double serializationPieter Wuille
2021-05-24Remove unused float serializationMarcoFalke
2020-10-09Support bypassing range check in ReadCompactSizePieter Wuille
This is needed when we want to encode an arbitrary number as CompactSize like node service flags, which is a bitmask and could be bigger than the usual size of an object.
2020-06-22refactor: Use uint16_t instead of unsigned shortAaron Hook
removed trailing whitespace to make linter happy
2020-05-24Remove old serialization primitivesPieter Wuille
2020-05-24Convert LimitedString to formatterPieter Wuille
2020-05-20Merge #18317: Serialization improvements step 6 (all except wallet/gui)MarcoFalke
f9ee0f37c28f604bc82dab502ce229c66ef5b3b9 Add comments to CustomUintFormatter (Pieter Wuille) 4eb5643e3538863c9d2ff261f49a9a1b248de243 Convert everything except wallet/qt to new serialization (Pieter Wuille) 2b1f85e8c52c8bc5a17eae4c809eaf61d724af98 Convert blockencodings_tests to new serialization (Pieter Wuille) 73747afbbeb013669faf4c4d2c0903cec4526fb0 Convert merkleblock to new serialization (Pieter Wuille) d06fedd1bc26bf5bf2b203d4445aeaebccca780e Add SER_READ and SER_WRITE for read/write-dependent statements (Russell Yanofsky) 6f9a1e5ad0a270d3b5a715f3e3ea0911193bf244 Extend CustomUintFormatter to support enums (Russell Yanofsky) 769ee5fa0011ae658770586442715452a656559d Merge BigEndian functionality into CustomUintFormatter (Pieter Wuille) Pull request description: The next step of changes from #10785. This: * Adds support for enum serialization to `CustomUintFormatter`, used in `CAddress` for service flags. * Merges `BigEndian` into `CustomUintFormatter`, used in `CNetAddr` for port numbers. * Converts everything (except wallet and gui) to use the new serialization framework. ACKs for top commit: MarcoFalke: re-ACK f9ee0f37c2, only change is new documentation commit for CustomUintFormatter 📂 ryanofsky: Code review ACK f9ee0f37c28f604bc82dab502ce229c66ef5b3b9. Just new commit adding comment since last review jonatack: Code review re-ACK f9ee0f37c28f604bc82dab502ce229c6 only change since last review is an additional commit adding Doxygen documentation for `CustomUintFormatter`. Tree-SHA512: e7a0a36afae592d5a4ff8c81ae04d858ac409388e361f2bc197d9a78abca45134218497ab2dfd6d031e0cce0ca586cf857077b7c6ce17fccf67e2d367c1b6cd4
2020-05-19Add comments to CustomUintFormatterPieter Wuille
2020-04-16scripted-diff: Bump copyright headersMarcoFalke
-BEGIN VERIFY SCRIPT- ./contrib/devtools/copyright_header.py update ./ -END VERIFY SCRIPT-
2020-03-30Add SER_READ and SER_WRITE for read/write-dependent statementsRussell Yanofsky
Extracted and extended by Pieter Wuille from a comment by Russ Yanofsky (see https://github.com/bitcoin/bitcoin/pull/18317#discussion_r398625457).
2020-03-30Extend CustomUintFormatter to support enumsRussell Yanofsky
Extracted by Pieter Wuille from a comment by Russ Yanofsky, see https://github.com/bitcoin/bitcoin/pull/18317#discussion_r398821936.
2020-03-30Merge BigEndian functionality into CustomUintFormatterPieter Wuille
2020-03-05Merge #18112: Serialization improvements step 5 (blockencodings)Wladimir J. van der Laan
353f376277ad9b87e03c9ccbc1028c4b6d12e8ea Convert blockencodings.h to new serialization framework (Pieter Wuille) e574fff53eec4a27c83b765cb69e31d8399047ea Add CustomUintFormatter (Pieter Wuille) 10633398f2dddf929d3f535aa48d138ad5e6c50f Add DifferenceFormatter (Russell Yanofsky) 56dd9f04c701aa3ac340e95065bf83de20373c8b Make VectorFormatter support stateful formatters (Russell Yanofsky) 3ca574cef0b4423f21b2c3efd8f5c9f71d52f219 Convert CCompactSize to proper formatter (Pieter Wuille) Pull request description: This is probably the most involved change in the sequence of changes extracted from #10785. In order to implement the differential encoding of BIP152, this change changes `VectorFormatter` to permit a stateful sub-formatter, which is then used by `DifferenceFormatter`. A `CustomUintFormatter` is added as well to do the 48-bit serialization of short ids. ACKs for top commit: laanwj: ACK 353f376277ad9b87e03c9ccbc1028c4b6d12e8ea, nice change ryanofsky: Code review ACK 353f376277ad9b87e03c9ccbc1028c4b6d12e8ea. Only changes since last review are suggested assert change and MASK->MAX rename Tree-SHA512: 976618991a8be62ba0738725b7cfa166a56cde998ebf1031ba6f28557032f1577b666ac7ae25cd498c0e1e740108c3c56a342620b724df41d6cc9d8bdafac037
2020-02-25Add CustomUintFormatterPieter Wuille
2020-02-19Add static_asserts to ser_X_to_Y() methodsSamer Afach
2020-02-17Fix a violation of C++ standard rules that unions cannot be switched.Samer Afach