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

use optimized rlp format for votes bundles #2878

Merged
Show file tree
Hide file tree
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
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
Loading