Skip to content

Commit

Permalink
use rebroadcast flag in onNewPbftVote method
Browse files Browse the repository at this point in the history
  • Loading branch information
JakubFornadel committed Apr 7, 2023
1 parent 89cebc4 commit 74944cd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
9 changes: 5 additions & 4 deletions libraries/core_libs/consensus/src/pbft/pbft_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,8 @@ void PbftManager::setPbftStep(PbftStep pbft_step) {
lambda_ = kMaxLambda;
}

LOG(log_nf_) << "No round progress - exponentially backing off lambda to " << lambda_.count() << " [ms] in step " << step_;
LOG(log_nf_) << "No round progress - exponentially backing off lambda to " << lambda_.count() << " [ms] in step "
<< step_;
}
}
}
Expand Down Expand Up @@ -590,11 +591,11 @@ void PbftManager::broadcastVotes() {
// Broadcast own votes
auto vote_packet_handler = net->getSpecificHandler<network::tarcap::VotePacketHandler>();
// TODO: this could be optimized to use VotesSyncPacketHandler if we drop some of the checks in process function
// TODO: onNewPbftVote does not use rebroadcast flag to force sending the votes
// Send votes by one as votes sync packet must contain votes with the same type, period and round
const auto& own_votes = vote_mgr_->getOwnVerifiedVotes();
const auto &own_votes = vote_mgr_->getOwnVerifiedVotes();
for (const auto &vote : own_votes) {
vote_packet_handler->onNewPbftVote(vote, getPbftProposedBlock(vote->getPeriod(), vote->getBlockHash()));
vote_packet_handler->onNewPbftVote(vote, getPbftProposedBlock(vote->getPeriod(), vote->getBlockHash()),
rebroadcast);
}
if (!own_votes.empty()) {
LOG(log_dg_) << "Broadcast own votes for period " << period << ", round " << round;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ class VotePacketHandler final : public ExtVotesPacketHandler {
*
* @param vote Votes to send
* @param block block to send - nullptr means no block
* @param rebroadcast - send even of vote i known for the peer
*/
void onNewPbftVote(const std::shared_ptr<Vote>& vote, const std::shared_ptr<PbftBlock>& block);
void onNewPbftVote(const std::shared_ptr<Vote>& vote, const std::shared_ptr<PbftBlock>& block,
bool rebroadcast = false);
void sendPbftVote(const std::shared_ptr<TaraxaPeer>& peer, const std::shared_ptr<Vote>& vote,
const std::shared_ptr<PbftBlock>& block);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,15 @@ void VotePacketHandler::process(const PacketData &packet_data, const std::shared
}
}

void VotePacketHandler::onNewPbftVote(const std::shared_ptr<Vote> &vote, const std::shared_ptr<PbftBlock> &block) {
void VotePacketHandler::onNewPbftVote(const std::shared_ptr<Vote> &vote, const std::shared_ptr<PbftBlock> &block,
bool rebroadcast) {
for (const auto &peer : peers_state_->getAllPeers()) {
if (peer.second->syncing_) {
LOG(log_dg_) << " PBFT vote " << vote->getHash() << " not sent to " << peer.first << " peer syncing";
continue;
}

if (peer.second->isVoteKnown(vote->getHash())) {
if (!rebroadcast && peer.second->isVoteKnown(vote->getHash())) {
continue;
}

Expand Down

0 comments on commit 74944cd

Please sign in to comment.