Skip to content

Commit

Permalink
use optimized rlp format for votes bundles
Browse files Browse the repository at this point in the history
  • Loading branch information
JakubFornadel committed Oct 29, 2024
1 parent 75fd5ea commit 4cc60c5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
#include "common/encoding_rlp.hpp"
#include "network/tarcap/packets_handlers/latest/common/exceptions.hpp"
#include "vote/pillar_vote.hpp"
#include "vote/votes_bundle_rlp.hpp"

namespace taraxa::network::tarcap {

struct PillarVotesBundlePacket {
// TODO[2870]: optimize rlp size (use custom class), see encodePillarVotesBundleRlp
std::vector<std::shared_ptr<PillarVote>> pillar_votes;

RLP_FIELDS_DEFINE_INPLACE(pillar_votes)
void rlp(::taraxa::util::RLPDecoderRef encoding) { pillar_votes = decodePillarVotesBundleRlp(encoding.value); }
void rlp(::taraxa::util::RLPEncoderRef encoding) const {
encoding.appendRaw(encodePillarVotesBundleRlp(pillar_votes));
}
};

} // namespace taraxa::network::tarcap
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,15 @@

#include "network/tarcap/packets_handlers/latest/common/exceptions.hpp"
#include "vote/pbft_vote.hpp"
#include "vote/votes_bundle_rlp.hpp"

namespace taraxa::network::tarcap {

struct VotesBundlePacket {
// TODO[2870]: Create votes bundles class
// blk_hash_t votes_bundle_block_hash;
// PbftPeriod votes_bundle_pbft_period;
// PbftRound votes_bundle_pbft_round;
// PbftStep votes_bundle_votes_step;

std::vector<std::shared_ptr<PbftVote>> votes;

// RLP_FIELDS_DEFINE_INPLACE(votes_bundle_block_hash, votes_bundle_pbft_period, votes_bundle_pbft_round,
// votes_bundle_votes_step, votes)
RLP_FIELDS_DEFINE_INPLACE(votes)
void rlp(::taraxa::util::RLPDecoderRef encoding) { votes = decodePbftVotesBundleRlp(encoding.value); }
void rlp(::taraxa::util::RLPEncoderRef encoding) const { encoding.appendRaw(encodePbftVotesBundleRlp(votes)); }
};

} // namespace taraxa::network::tarcap

0 comments on commit 4cc60c5

Please sign in to comment.