Skip to content
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

revert #1999 structs.hpp #2016

Merged
merged 1 commit into from
Mar 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions core/consensus/grandpa/structs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,42 @@ namespace kagome::consensus::grandpa {
using SignedMessage::SignedMessage;
};

template <class Stream,
typename = std::enable_if_t<Stream::is_encoder_stream>>
Stream &operator<<(Stream &s, const SignedPrevote &signed_msg) {
assert(signed_msg.template is<Prevote>());
return s << boost::strict_get<Prevote>(signed_msg.message)
<< signed_msg.signature << signed_msg.id;
}

template <class Stream,
typename = std::enable_if_t<Stream::is_decoder_stream>>
Stream &operator>>(Stream &s, SignedPrevote &signed_msg) {
signed_msg.message = Prevote{};
return s >> boost::strict_get<Prevote>(signed_msg.message)
>> signed_msg.signature >> signed_msg.id;
}

class SignedPrecommit : public SignedMessage {
using SignedMessage::SignedMessage;
};

template <class Stream,
typename = std::enable_if_t<Stream::is_encoder_stream>>
Stream &operator<<(Stream &s, const SignedPrecommit &signed_msg) {
assert(signed_msg.template is<Precommit>());
return s << boost::strict_get<Precommit>(signed_msg.message)
<< signed_msg.signature << signed_msg.id;
}

template <class Stream,
typename = std::enable_if_t<Stream::is_decoder_stream>>
Stream &operator>>(Stream &s, SignedPrecommit &signed_msg) {
signed_msg.message = Precommit{};
return s >> boost::strict_get<Precommit>(signed_msg.message)
>> signed_msg.signature >> signed_msg.id;
}

// justification that contains a list of signed precommits justifying the
// validity of the block
struct GrandpaJustification {
Expand Down
Loading