Skip to content

Commit

Permalink
Merge pull request #2878 from Taraxa-project/issue-2870/votes_bundles…
Browse files Browse the repository at this point in the history
…_optimization

use optimized rlp format for votes bundles
  • Loading branch information
JakubFornadel authored Oct 30, 2024
2 parents 75fd5ea + 4cc60c5 commit c742907
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 c742907

Please sign in to comment.