#339 - fix active_sidechain_types for peerplays_sidechain_plugin

This commit is contained in:
Vlad Dobromyslov 2022-04-07 14:50:41 +03:00
parent e58b7d6916
commit b09c22b224

View file

@ -310,22 +310,22 @@ const son_object peerplays_sidechain_plugin_impl::get_son_object(son_id_type son
return *son_obj; return *son_obj;
} }
//! Fixme - do we need to provide sidechain_type as param for this function?
bool peerplays_sidechain_plugin_impl::is_active_son(son_id_type son_id) { bool peerplays_sidechain_plugin_impl::is_active_son(son_id_type son_id) {
const auto &idx = plugin.database().get_index_type<chain::son_index>().indices().get<by_id>(); const auto &idx = plugin.database().get_index_type<chain::son_index>().indices().get<by_id>();
auto son_obj = idx.find(son_id); auto son_obj = idx.find(son_id);
if (son_obj == idx.end()) if (son_obj == idx.end())
return false; return false;
//! Fixme - now only bitcoin, fix according to sidechain_type
const chain::global_property_object &gpo = plugin.database().get_global_properties(); const chain::global_property_object &gpo = plugin.database().get_global_properties();
vector<son_id_type> active_son_ids; set<son_id_type> active_son_ids;
active_son_ids.reserve(gpo.active_sons.at(sidechain_type::bitcoin).size()); for(const auto& active_sidechain_type : active_sidechain_types) {
std::transform(gpo.active_sons.at(sidechain_type::bitcoin).cbegin(), gpo.active_sons.at(sidechain_type::bitcoin).cend(), std::transform(gpo.active_sons.at(active_sidechain_type).cbegin(), gpo.active_sons.at(active_sidechain_type).cend(),
std::inserter(active_son_ids, active_son_ids.end()), std::inserter(active_son_ids, active_son_ids.end()),
[](const son_info &swi) { [](const son_info &swi) {
return swi.son_id; return swi.son_id;
}); });
}
auto it = std::find(active_son_ids.begin(), active_son_ids.end(), son_id); auto it = std::find(active_son_ids.begin(), active_son_ids.end(), son_id);
@ -456,9 +456,13 @@ void peerplays_sidechain_plugin_impl::schedule_son_processing() {
} }
void peerplays_sidechain_plugin_impl::son_processing() { void peerplays_sidechain_plugin_impl::son_processing() {
//! Fixme - here we must check size for every sidechain //! Check whether we have active SONs
if (plugin.database().get_global_properties().active_sons.at(sidechain_type::bitcoin).size() <= 0 && bool have_active_sons = false;
plugin.database().get_global_properties().active_sons.at(sidechain_type::hive).size() <= 0) { for(const auto& active_sidechain_type : active_sidechain_types) {
if(plugin.database().get_global_properties().active_sons.at(active_sidechain_type).size() >= 0)
have_active_sons = true;
}
if (!have_active_sons) {
return; return;
} }