6 #ifndef IROHA_YAC_PB_CONVERTERS_HPP 7 #define IROHA_YAC_PB_CONVERTERS_HPP 22 static inline proto::Vote serializeRoundAndHashes(
26 auto hash = pb_vote.mutable_hash();
27 auto hash_round =
hash->mutable_vote_round();
30 auto hash_vote_hashes =
hash->mutable_vote_hashes();
37 static inline VoteMessage deserealizeRoundAndHashes(
38 const proto::Vote &pb_vote) {
43 pb_vote.hash().vote_round().reject_round()};
46 pb_vote.hash().vote_hashes().block()};
53 auto pb_vote = serializeRoundAndHashes(vote);
56 auto block_signature =
57 pb_vote.mutable_hash()->mutable_block_signature();
62 block_signature->set_signature(std::move(signature).assumeValue());
63 block_signature->set_pubkey(std::move(public_key).assumeValue());
70 auto pb_vote = serializeRoundAndHashes(vote);
73 auto block_signature =
74 pb_vote.mutable_hash()->mutable_block_signature();
79 block_signature->set_signature(std::move(signature).assumeValue());
80 block_signature->set_pubkey(std::move(public_key).assumeValue());
83 auto vote_signature = pb_vote.mutable_signature();
88 vote_signature->set_signature(std::move(signature).assumeValue());
89 vote_signature->set_pubkey(std::move(public_key).assumeValue());
98 static const uint64_t kMaxBatchSize{0};
104 std::make_shared<shared_model::validation::ValidatorsConfig>(
107 auto vote = deserealizeRoundAndHashes(pb_vote);
109 auto deserialize = [&](
auto &pubkey,
114 using shared_model::interface::types::PublicKeyHexStringView;
115 using shared_model::interface::types::SignedHexStringView;
117 .createSignature(PublicKeyHexStringView{pubkey_hex},
118 SignedHexStringView{signature_hex})
120 [&](
auto &&sig) -> boost::optional<std::unique_ptr<
122 return std::move(sig).value;
124 [&](
const auto &reason)
125 -> boost::optional<std::unique_ptr<
127 log->error(msg, reason.error);
132 if (pb_vote.hash().has_block_signature()) {
133 if (
auto block_signature =
134 deserialize(pb_vote.hash().block_signature().pubkey(),
135 pb_vote.hash().block_signature().signature(),
136 "Cannot build vote hash block signature: {}")) {
137 vote.hash.block_signature = *std::move(block_signature);
143 if (
auto vote_signature =
144 deserialize(pb_vote.signature().pubkey(),
145 pb_vote.signature().signature(),
146 "Cannot build vote signature: {}")) {
147 vote.signature = *std::move(vote_signature);
159 #endif // IROHA_YAC_PB_CONVERTERS_HPP Definition: signature.hpp:18
std::string bytestringToHexstring(std::string_view str)
Definition: hexutils.hpp:51
std::shared_ptr< shared_model::interface::Signature > block_signature
Definition: yac_hash_provider.hpp:72
std::shared_ptr< shared_model::interface::Signature > signature
Definition: vote_message.hpp:24
std::shared_ptr< Logger > LoggerPtr
Definition: logger_fwd.hpp:22
Definition: proto_common_objects_factory.hpp:32
static boost::optional< VoteMessage > deserializeVote(const proto::Vote &pb_vote, logger::LoggerPtr log)
Definition: yac_pb_converters.hpp:94
Definition: block_query.hpp:15
hash256_t hash(const T &pb)
Definition: pb_common.hpp:43
YacHash hash
Definition: vote_message.hpp:23
Definition: yac_hash_provider.hpp:48
BlockRoundType block_round
Definition: round.hpp:32
Definition: field_validator.hpp:41
RejectRoundType reject_round
Definition: round.hpp:33
Definition: yac_pb_converters.hpp:20
ProposalHash proposal_hash
Definition: yac_hash_provider.hpp:52
static proto::Vote serializeVote(const VoteMessage &vote)
Definition: yac_pb_converters.hpp:69
VoteHashes vote_hashes
Definition: yac_hash_provider.hpp:67
Definition: vote_message.hpp:22
BlockHash block_hash
Definition: yac_hash_provider.hpp:57
static proto::Vote serializeVotePayload(const VoteMessage &vote)
Definition: yac_pb_converters.hpp:52
iroha::expected::Result< std::string, const char * > hexstringToBytestringResult(std::string_view str)
Definition: hexutils.hpp:65
Round vote_round
Definition: yac_hash_provider.hpp:43