-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Support serialization of std::vector<bool> #16730
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
ACK 92528c2 (only looked at the diff on GitHub) |
ACK 92528c2 -- diff looks correct Related: #16572 (comment)
|
ACK 92528c2 Low-risk change, reviewed on Github. |
92528c2 Support serialization of std::vector<bool> (Pieter Wuille) Pull request description: This adds support for serialization of `std::vector<bool>`, as a prerequisite of #16702. ACKs for top commit: MarcoFalke: ACK 92528c2 (only looked at the diff on GitHub) practicalswift: ACK 92528c2 -- diff looks correct jamesob: ACK 92528c2 Tree-SHA512: 068246a55a889137098f817bf72d99fc3218a560d62a97c59cccc0392b110f6778843cee4e89d56f271ac64e03a0f64dc5e2cc22daa833fbbbe9234c5f42d7b9
ACK 92528c2
|
We don't want to define serialization to be a bit vector? We're not using a |
@JeremyRubin It's just for hashing, it doesn't really matter. |
@JeremyRubin Longer answer: I think the expected serialization of |
I would think the reason to worry about the serialization for hashing with a bitpacked array is that the incoming message can be hashed and it will be equivalent to the hash of the deserializaed struct. Agree the best way to do this is by having a different type for a BitPacked serialization. |
Summary: PR description: > This adds support for serialization of std::vector<bool>, as a prerequisite of [[bitcoin/bitcoin#16702 | PR16702]]. Backport of Core [[bitcoin/bitcoin#16730 | PR16730]]. Test Plan: `ninja && ninja check` Reviewers: O1 Bitcoin ABC, #bitcoin_abc, deadalnix Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, deadalnix Subscribers: deadalnix Differential Revision: https://reviews.bitcoinabc.org/D7907
bitcoin/bitcoin#16730 Without this fix we got a following error: no member named 'Serialize' in 'std::__1::__bit_const_reference<std::__1::vector<bool, std::__1::allocator<bool> > >' during clang build.
bitcoin/bitcoin#16730 Without this fix we got a following error: no member named 'Serialize' in 'std::__1::__bit_const_reference<std::__1::vector<bool, std::__1::allocator<bool> > >' during clang build.
merge bitcoin#17812, bitcoin#16702, bitcoin#16730, bitcoin#18023: supplying and using asmap to improve IP bucketing in addrman
bitcoin/bitcoin#16730 Without this fix we got a following error: no member named 'Serialize' in 'std::__1::__bit_const_reference<std::__1::vector<bool, std::__1::allocator<bool> > >' during clang build.
bbd14ce Support serialization of std::vector<bool> (Pieter Wuille) Pull request description: Backport of bitcoin#16730, fixing the following clang warning: ``` ./serialize.h:631:44: warning: loop variable 'elem' is always a copy because the range of type 'const std::vector<bool, std::allocator<bool> >' does not return a reference [-Wrange-loop-analysis] for (const typename V::value_type& elem : v) { ^ ./serialize.h:484:77: note: in instantiation of function template specialization 'VectorFormatter<DefaultFormatter>::Ser<CHashWriter, std::vector<bool, std::allocator<bool> > >' requested here template<typename Stream> void Serialize(Stream &s) const { Formatter().Ser(s, m_object); } ^ ./serialize.h:806:7: note: in instantiation of function template specialization 'Wrapper<VectorFormatter<DefaultFormatter>, const std::vector<bool, std::allocator<bool> > &>::Serialize<CHashWriter>' requested here a.Serialize(os); ^ ./serialize.h:956:5: note: in instantiation of function template specialization 'Serialize<CHashWriter, Wrapper<VectorFormatter<DefaultFormatter>, const std::vector<bool, std::allocator<bool> > &> >' requested here Serialize(os, Using<VectorFormatter<DefaultFormatter>>(v)); ^ ./serialize.h:962:5: note: in instantiation of function template specialization 'Serialize_impl<CHashWriter, bool, std::allocator<bool>, bool>' requested here Serialize_impl(os, v, T()); ^ ./hash.h:247:11: note: in instantiation of function template specialization 'Serialize<CHashWriter, bool, std::allocator<bool> >' requested here ::Serialize(*this, obj); ^ ./hash.h:292:8: note: in instantiation of function template specialization 'CHashWriter::operator<<<std::vector<bool, std::allocator<bool> > >' requested here ss << obj; ^ init.cpp:1504:39: note: in instantiation of function template specialization 'SerializeHash<std::vector<bool, std::allocator<bool> > >' requested here const uint256 asmap_version = SerializeHash(asmap); ``` ACKs for top commit: furszy: good finding, utACK bbd14ce Tree-SHA512: ff26242545f727e6f6925e2f4f63f2616d89306c0bcc42bdf778eae95b85673ae5062637601fb5a27b49cb793de2ec144abcb2af63f62c18a0edbac5e07aea68
This adds support for serialization of
std::vector<bool>
, as a prerequisite of #16702.