Skip to content

Commit

Permalink
GH-1547 Minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
heifner committed Aug 26, 2023
1 parent dd9802a commit 86c4305
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
11 changes: 5 additions & 6 deletions libraries/hotstuff/include/eosio/hotstuff/qc_chain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace eosio::hotstuff {

class quorum_certificate {
public:
explicit quorum_certificate(uint32_t finalizer_size = 0) {
explicit quorum_certificate(size_t finalizer_size = 0) {
active_finalizers.resize(finalizer_size);
}

Expand All @@ -48,17 +48,16 @@ namespace eosio::hotstuff {
.active_agg_sig = active_agg_sig};
}

void reset(const fc::sha256& proposal, uint32_t finalizer_size) {
void reset(const fc::sha256& proposal, size_t finalizer_size) {
proposal_id = proposal;
active_finalizers.clear();
active_finalizers.resize(finalizer_size);
active_finalizers = boost::dynamic_bitset<>{finalizer_size};
active_agg_sig = fc::crypto::blslib::bls_signature();
quorum_met = false;
}

boost::dynamic_bitset<> get_active_finalizers() const {
const boost::dynamic_bitset<>& get_active_finalizers() const {
assert(!active_finalizers.empty());
return boost::dynamic_bitset(active_finalizers);
return active_finalizers;
}
void set_active_finalizers(const boost::dynamic_bitset<>& bs) {
assert(!bs.empty());
Expand Down
6 changes: 3 additions & 3 deletions libraries/hotstuff/qc_chain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,15 +225,15 @@ namespace eosio { namespace hotstuff {

bool qc_chain::evaluate_quorum(const extended_schedule& es, const boost::dynamic_bitset<>& finalizers, const fc::crypto::blslib::bls_signature& agg_sig, const hs_proposal_message& proposal) {

bool first = true;

if (positive_bits_count(finalizers) < _pacemaker->get_quorum_threshold()){
return false;
}

fc::crypto::blslib::bls_public_key agg_key;

for (boost::dynamic_bitset<>::size_type i = 0; i < finalizers.size(); i++) {
bool first = true;
for (boost::dynamic_bitset<>::size_type i = 0; i < finalizers.size(); ++i) {
if (finalizers[i]){
//adding finalizer's key to the aggregate pub key
if (first) {
Expand Down Expand Up @@ -493,7 +493,7 @@ namespace eosio { namespace hotstuff {

auto increment_version = fc::make_scoped_exit([this]() { ++_state_version; });

boost::dynamic_bitset finalizer_set = _current_qc.get_active_finalizers();
const boost::dynamic_bitset<>& finalizer_set = _current_qc.get_active_finalizers();
if (finalizer_set.any())
_current_qc.set_active_agg_sig(fc::crypto::blslib::aggregate({_current_qc.get_active_agg_sig(), vote.sig }));
else
Expand Down

0 comments on commit 86c4305

Please sign in to comment.