Skip to content

Commit

Permalink
GH-376 Do not include vote count in received qc comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
heifner committed Jul 23, 2024
1 parent 104bb14 commit d00c767
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 12 deletions.
12 changes: 1 addition & 11 deletions libraries/chain/finality/qc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ inline std::vector<uint32_t> bitset_to_vector(const vote_bitset& bs) {
return r;
}

size_t qc_sig_t::vote_count() const {
return (strong_votes ? strong_votes->count() : 0u) +
(weak_votes ? weak_votes->count() : 0u);
}

void qc_sig_t::verify(const finalizer_policy_ptr& fin_policy,
const digest_type& strong_digest,
const weak_digest_t& weak_digest) const {
Expand Down Expand Up @@ -284,12 +279,7 @@ std::optional<qc_sig_t> open_qc_sig_t::get_best_qc() const {

bool open_qc_sig_t::set_received_qc_sig(const qc_sig_t& qc) {
std::lock_guard g(*_mtx);
const bool qc_is_better =
!received_qc_sig
|| (received_qc_sig->is_weak() && qc.is_strong())
|| received_qc_sig->vote_count() < qc.vote_count();

if (qc_is_better) {
if (!received_qc_sig || (received_qc_sig->is_weak() && qc.is_strong())) {
received_qc_sig = qc;
return true;
}
Expand Down
1 change: 0 additions & 1 deletion libraries/chain/include/eosio/chain/finality/qc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ namespace eosio::chain {
struct qc_sig_t {
bool is_weak() const { return !!weak_votes; }
bool is_strong() const { return !weak_votes; }
size_t vote_count() const;

std::optional<vote_bitset> strong_votes;
std::optional<vote_bitset> weak_votes;
Expand Down

0 comments on commit d00c767

Please sign in to comment.