From 6fe0acb12d1d86fa0f218dfe4cdb06f67e6b1716 Mon Sep 17 00:00:00 2001 From: Srdjan Obucina Date: Mon, 13 Jan 2020 16:05:28 +0100 Subject: [PATCH] Fix build errors --- libraries/chain/db_maint.cpp | 16 ++++++++-------- .../peerplays_sidechain_plugin.cpp | 13 +++++++++++-- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/libraries/chain/db_maint.cpp b/libraries/chain/db_maint.cpp index df23cd10..7b111fd4 100644 --- a/libraries/chain/db_maint.cpp +++ b/libraries/chain/db_maint.cpp @@ -502,19 +502,19 @@ void database::update_active_sons() obj.network_fee_percentage = GRAPHENE_DEFAULT_NETWORK_PERCENT_OF_FEE; obj.lifetime_referrer_fee_percentage = GRAPHENE_100_PERCENT - GRAPHENE_DEFAULT_NETWORK_PERCENT_OF_FEE; - for( const auto& son_id : gpo.active_sons ) + for( const auto& son_info : gpo.active_sons ) { - const son_object& son = get(son_id); + const son_object& son = get(son_info.son_id); total_votes += _vote_tally_buffer[son.vote_id]; } // total_votes is 64 bits. Subtract the number of leading low bits from 64 to get the number of useful bits, // then I want to keep the most significant 16 bits of what's left. int8_t bits_to_drop = std::max(int(boost::multiprecision::detail::find_msb(total_votes)) - 15, 0); - for( const auto& son_id : gpo.active_sons ) + for( const auto& son_info : gpo.active_sons ) { // Ensure that everyone has at least one vote. Zero weights aren't allowed. - const son_object& son = get(son_id); + const son_object& son = get(son_info.son_id); uint16_t votes = std::max((_vote_tally_buffer[son.vote_id] >> bits_to_drop), uint64_t(1) ); obj.active.account_auths[son.son_account] += votes; obj.active.weight_threshold += votes; @@ -533,18 +533,18 @@ void database::update_active_sons() modify( get(gpo.parameters.get_son_btc_account_id()), [&]( account_object& obj ) { uint64_t total_votes = 0; - for( const auto& son_id : gpo.active_sons ) + for( const auto& son_info : gpo.active_sons ) { - const son_object& son = get(son_id); + const son_object& son = get(son_info.son_id); total_votes += _vote_tally_buffer[son.vote_id]; } // total_votes is 64 bits. Subtract the number of leading low bits from 64 to get the number of useful bits, // then I want to keep the most significant 16 bits of what's left. int8_t bits_to_drop = std::max(int(boost::multiprecision::detail::find_msb(total_votes)) - 15, 0); - for( const auto& son_id : gpo.active_sons ) + for( const auto& son_info : gpo.active_sons ) { // Ensure that everyone has at least one vote. Zero weights aren't allowed. - const son_object& son = get(son_id); + const son_object& son = get(son_info.son_id); uint16_t votes = std::max((_vote_tally_buffer[son.vote_id] >> bits_to_drop), uint64_t(1) ); obj.active.account_auths[son.son_account] += votes; obj.active.weight_threshold += votes; diff --git a/libraries/plugins/peerplays_sidechain/peerplays_sidechain_plugin.cpp b/libraries/plugins/peerplays_sidechain/peerplays_sidechain_plugin.cpp index 0a6b4964..3dc48b6a 100644 --- a/libraries/plugins/peerplays_sidechain/peerplays_sidechain_plugin.cpp +++ b/libraries/plugins/peerplays_sidechain/peerplays_sidechain_plugin.cpp @@ -182,8 +182,17 @@ void peerplays_sidechain_plugin_impl::heartbeat_loop() chain::database& d = plugin.database(); chain::son_id_type son_id = *(_sons.begin()); const chain::global_property_object& gpo = d.get_global_properties(); - auto it = std::find(gpo.active_sons.begin(), gpo.active_sons.end(), son_id); - if(it != gpo.active_sons.end()) { + + vector active_son_ids; + active_son_ids.reserve(gpo.active_sons.size()); + std::transform(gpo.active_sons.begin(), gpo.active_sons.end(), + std::inserter(active_son_ids, active_son_ids.end()), + [](const son_info& swi) { + return swi.son_id; + }); + + auto it = std::find(active_son_ids.begin(), active_son_ids.end(), son_id); + if(it != active_son_ids.end()) { ilog("peerplays_sidechain_plugin: sending heartbeat"); chain::son_heartbeat_operation op; const auto& idx = d.get_index_type().indices().get();