Skip to content

Commit

Permalink
GH-2102 Init processed on reflection
Browse files Browse the repository at this point in the history
  • Loading branch information
heifner committed Apr 4, 2024
1 parent 4066109 commit 9411c05
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
9 changes: 9 additions & 0 deletions libraries/chain/hotstuff/hotstuff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ bool pending_quorum_certificate::has_voted_no_lock(bool strong, size_t index) co
return _weak_votes.has_voted(index);
}

void pending_quorum_certificate::votes_t::reflector_init() {
_processed = std::vector<std::atomic<bool>>(_bitset.size());
for (size_t i = 0; i < _bitset.size(); ++i) {
if (_bitset[i]) {
_processed[i].store(true, std::memory_order_relaxed);
}
}
}

bool pending_quorum_certificate::votes_t::has_voted(size_t index) const {
assert(index <= _processed.size());
return _processed[index].load(std::memory_order_relaxed);
Expand Down
6 changes: 5 additions & 1 deletion libraries/chain/include/eosio/chain/hotstuff/hotstuff.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,18 @@ namespace eosio::chain {
strong // Enough `strong` votes to have a valid `strong` QC
};

struct votes_t {
struct votes_t : fc::reflect_init {
private:
friend struct fc::reflector<votes_t>;
friend struct fc::reflector_init_visitor<votes_t>;
friend struct fc::has_reflector_init<votes_t>;
friend class pending_quorum_certificate;

hs_bitset _bitset;
bls_aggregate_signature _sig;
std::vector<std::atomic<bool>> _processed; // avoid locking mutex for _bitset duplicate check

void reflector_init();
public:
explicit votes_t(size_t num_finalizers)
: _bitset(num_finalizers)
Expand Down

0 comments on commit 9411c05

Please sign in to comment.