diff --git a/libraries/chain/hotstuff/hotstuff.cpp b/libraries/chain/hotstuff/hotstuff.cpp index 1aaffabfad..262efde066 100644 --- a/libraries/chain/hotstuff/hotstuff.cpp +++ b/libraries/chain/hotstuff/hotstuff.cpp @@ -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>(_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); diff --git a/libraries/chain/include/eosio/chain/hotstuff/hotstuff.hpp b/libraries/chain/include/eosio/chain/hotstuff/hotstuff.hpp index f67f7d65be..7fae2ceb78 100644 --- a/libraries/chain/include/eosio/chain/hotstuff/hotstuff.hpp +++ b/libraries/chain/include/eosio/chain/hotstuff/hotstuff.hpp @@ -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; + friend struct fc::reflector_init_visitor; + friend struct fc::has_reflector_init; friend class pending_quorum_certificate; + hs_bitset _bitset; bls_aggregate_signature _sig; std::vector> _processed; // avoid locking mutex for _bitset duplicate check + void reflector_init(); public: explicit votes_t(size_t num_finalizers) : _bitset(num_finalizers)