diff --git a/libraries/core_libs/network/include/network/tarcap/packets/latest/pillar_votes_bundle_packet.hpp b/libraries/core_libs/network/include/network/tarcap/packets/latest/pillar_votes_bundle_packet.hpp index bf2bf1f632..eb9e4061bf 100644 --- a/libraries/core_libs/network/include/network/tarcap/packets/latest/pillar_votes_bundle_packet.hpp +++ b/libraries/core_libs/network/include/network/tarcap/packets/latest/pillar_votes_bundle_packet.hpp @@ -8,12 +8,9 @@ namespace taraxa::network::tarcap { struct PillarVotesBundlePacket { - std::vector> pillar_votes; + OptimizedPillarVotesBundle pillar_votes_bundle; - void rlp(::taraxa::util::RLPDecoderRef encoding) { pillar_votes = decodePillarVotesBundleRlp(encoding.value); } - void rlp(::taraxa::util::RLPEncoderRef encoding) const { - encoding.appendRaw(encodePillarVotesBundleRlp(pillar_votes)); - } + RLP_FIELDS_DEFINE_INPLACE(pillar_votes_bundle) }; } // namespace taraxa::network::tarcap diff --git a/libraries/core_libs/network/src/tarcap/packets_handlers/latest/get_pillar_votes_bundle_packet_handler.cpp b/libraries/core_libs/network/src/tarcap/packets_handlers/latest/get_pillar_votes_bundle_packet_handler.cpp index 9885cb638c..9c36e9d304 100644 --- a/libraries/core_libs/network/src/tarcap/packets_handlers/latest/get_pillar_votes_bundle_packet_handler.cpp +++ b/libraries/core_libs/network/src/tarcap/packets_handlers/latest/get_pillar_votes_bundle_packet_handler.cpp @@ -52,7 +52,7 @@ void GetPillarVotesBundlePacketHandler::process(GetPillarVotesBundlePacket &&pac for (size_t i = 0; i < chunk_size; ++i) { pillar_votes.emplace_back(votes[votes_sent + i]); } - PillarVotesBundlePacket pillar_votes_bundle_packet(std::move(pillar_votes)); + PillarVotesBundlePacket pillar_votes_bundle_packet(OptimizedPillarVotesBundle{std::move(pillar_votes)}); // Seal and send the chunk to the peer if (sealAndSend(peer->getId(), SubprotocolPacketType::kPillarVotesBundlePacket, diff --git a/libraries/core_libs/network/src/tarcap/packets_handlers/latest/pillar_votes_bundle_packet_handler.cpp b/libraries/core_libs/network/src/tarcap/packets_handlers/latest/pillar_votes_bundle_packet_handler.cpp index dce719e0e5..cbbf4e3177 100644 --- a/libraries/core_libs/network/src/tarcap/packets_handlers/latest/pillar_votes_bundle_packet_handler.cpp +++ b/libraries/core_libs/network/src/tarcap/packets_handlers/latest/pillar_votes_bundle_packet_handler.cpp @@ -14,15 +14,16 @@ PillarVotesBundlePacketHandler::PillarVotesBundlePacketHandler( void PillarVotesBundlePacketHandler::process(PillarVotesBundlePacket &&packet, const std::shared_ptr &peer) { - if (packet.pillar_votes.size() == 0 || packet.pillar_votes.size() > kMaxPillarVotesInBundleRlp) { - throw InvalidRlpItemsCountException("PillarVotesBundlePacket", packet.pillar_votes.size(), + if (packet.pillar_votes_bundle.pillar_votes.size() == 0 || + packet.pillar_votes_bundle.pillar_votes.size() > kMaxPillarVotesInBundleRlp) { + throw InvalidRlpItemsCountException("PillarVotesBundlePacket", packet.pillar_votes_bundle.pillar_votes.size(), kMaxPillarVotesInBundleRlp); } // TODO[2744]: there could be the same protection as in pbft syncing that only requested bundle packet is accepted LOG(log_dg_) << "PillarVotesBundlePacket received from peer " << peer->getId(); - for (const auto &pillar_vote : packet.pillar_votes) { + for (const auto &pillar_vote : packet.pillar_votes_bundle.pillar_votes) { if (!kConf.genesis.state.hardforks.ficus_hf.isFicusHardfork(pillar_vote->getPeriod())) { std::ostringstream err_msg; err_msg << "Synced pillar vote " << pillar_vote->getHash() << ", period " << pillar_vote->getPeriod() diff --git a/libraries/types/vote/include/vote/votes_bundle_rlp.hpp b/libraries/types/vote/include/vote/votes_bundle_rlp.hpp index a7a794f572..2975dc455f 100644 --- a/libraries/types/vote/include/vote/votes_bundle_rlp.hpp +++ b/libraries/types/vote/include/vote/votes_bundle_rlp.hpp @@ -16,6 +16,7 @@ class PillarVote; * @{ */ +// TOOD[2865]: move to cpp file constexpr static size_t kPbftVotesBundleRlpSize{5}; /**