6 #ifndef IROHA_YAC_PB_CONVERTERS_HPP 7 #define IROHA_YAC_PB_CONVERTERS_HPP 20 static inline proto::Vote serializeRoundAndHashes(
const VoteMessage &vote) {
23 auto hash = pb_vote.mutable_hash();
24 auto hash_round =
hash->mutable_vote_round();
27 auto hash_vote_hashes =
hash->mutable_vote_hashes();
34 static inline VoteMessage deserealizeRoundAndHashes(
35 const proto::Vote &pb_vote) {
39 pb_vote.hash().vote_round().reject_round()};
42 pb_vote.hash().vote_hashes().block()};
49 auto pb_vote = serializeRoundAndHashes(vote);
52 auto block_signature =
53 pb_vote.mutable_hash()->mutable_block_signature();
58 block_signature->set_signature(std::move(signature).assumeValue());
59 block_signature->set_pubkey(std::move(public_key).assumeValue());
66 auto pb_vote = serializeRoundAndHashes(vote);
69 auto block_signature =
70 pb_vote.mutable_hash()->mutable_block_signature();
75 block_signature->set_signature(std::move(signature).assumeValue());
76 block_signature->set_pubkey(std::move(public_key).assumeValue());
79 auto vote_signature = pb_vote.mutable_signature();
84 vote_signature->set_signature(std::move(signature).assumeValue());
85 vote_signature->set_pubkey(std::move(public_key).assumeValue());
94 static const uint64_t kMaxBatchSize{0};
99 factory{std::make_shared<shared_model::validation::ValidatorsConfig>(
102 auto vote = deserealizeRoundAndHashes(pb_vote);
104 auto deserialize = [&](
auto &pubkey,
auto &signature,
const auto &msg) {
107 using shared_model::interface::types::PublicKeyHexStringView;
108 using shared_model::interface::types::SignedHexStringView;
110 .createSignature(PublicKeyHexStringView{pubkey_hex},
111 SignedHexStringView{signature_hex})
115 std::unique_ptr<shared_model::interface::Signature>> {
116 return std::move(sig).value;
118 [&](
const auto &reason)
120 std::unique_ptr<shared_model::interface::Signature>> {
121 log->error(msg, reason.error);
126 if (pb_vote.hash().has_block_signature()) {
127 if (
auto block_signature =
128 deserialize(pb_vote.hash().block_signature().pubkey(),
129 pb_vote.hash().block_signature().signature(),
130 "Cannot build vote hash block signature: {}")) {
131 vote.hash.block_signature = *std::move(block_signature);
137 if (
auto vote_signature =
138 deserialize(pb_vote.signature().pubkey(),
139 pb_vote.signature().signature(),
140 "Cannot build vote signature: {}")) {
141 vote.signature = *std::move(vote_signature);
151 #endif // IROHA_YAC_PB_CONVERTERS_HPP 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:67
std::shared_ptr< shared_model::interface::Signature > signature
Definition: vote_message.hpp:22
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:90
hash256_t hash(const T &pb)
Definition: pb_common.hpp:43
YacHash hash
Definition: vote_message.hpp:21
Definition: yac_hash_provider.hpp:43
BlockRoundType block_round
Definition: round.hpp:32
Definition: field_validator.hpp:41
RejectRoundType reject_round
Definition: round.hpp:33
Definition: yac_pb_converters.hpp:18
ProposalHash proposal_hash
Definition: yac_hash_provider.hpp:47
static proto::Vote serializeVote(const VoteMessage &vote)
Definition: yac_pb_converters.hpp:65
VoteHashes vote_hashes
Definition: yac_hash_provider.hpp:62
Definition: vote_message.hpp:20
BlockHash block_hash
Definition: yac_hash_provider.hpp:52
static proto::Vote serializeVotePayload(const VoteMessage &vote)
Definition: yac_pb_converters.hpp:48
iroha::expected::Result< std::string, const char * > hexstringToBytestringResult(std::string_view str)
Definition: hexutils.hpp:65
Round vote_round
Definition: yac_hash_provider.hpp:38
Definition: cluster_order.hpp:16