Skip to content

Commit

Permalink
Merge branch 'develop' into 'beatrice'
Browse files Browse the repository at this point in the history
Fixes for 1.5.24-beta

See merge request PBSA/peerplays!246
  • Loading branch information
Vlad Dobromyslov committed Aug 23, 2023
2 parents 9fe3513 + f0654e5 commit aa099f9
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
4 changes: 2 additions & 2 deletions libraries/chain/db_maint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2283,7 +2283,7 @@ void database::perform_son_tasks()
// Add vote_ids for HIVE and ETHEREUM to all existing SONs
const auto &all_sons = get_index_type<son_index>().indices().get<by_id>();
for (const son_object &son : all_sons) {
vote_id_type existing_vote_id_bitcoin;
const auto existing_vote_id_bitcoin = son.get_bitcoin_vote_id();
vote_id_type new_vote_id_hive;
vote_id_type new_vote_id_eth;

Expand All @@ -2300,7 +2300,7 @@ void database::perform_son_tasks()
// Duplicate all votes from bitcoin to hive
const auto &all_accounts = get_index_type<account_index>().indices().get<by_id>();
for (const auto &account : all_accounts) {
if (account.options.votes.count(existing_vote_id_bitcoin) != 0) {
if (existing_vote_id_bitcoin.valid() && account.options.votes.count(*existing_vote_id_bitcoin) != 0) {
modify(account, [new_vote_id_hive](account_object &a) {
a.options.votes.insert(new_vote_id_hive);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ class peerplays_sidechain_plugin_impl {
uint16_t retries_threshold = 150;

bool first_block_skipped;
bool son_processing_enabled;
void on_applied_block(const signed_block &b);
};

Expand Down Expand Up @@ -135,7 +136,8 @@ peerplays_sidechain_plugin_impl::peerplays_sidechain_plugin_impl(peerplays_sidec
}
return net_handlers;
}()),
first_block_skipped(false) {
first_block_skipped(false),
son_processing_enabled(false) {
}

peerplays_sidechain_plugin_impl::~peerplays_sidechain_plugin_impl() {
Expand Down Expand Up @@ -871,7 +873,19 @@ void peerplays_sidechain_plugin_impl::settle_sidechain_transactions(sidechain_ty

void peerplays_sidechain_plugin_impl::on_applied_block(const signed_block &b) {
if (first_block_skipped) {
schedule_son_processing();
if(son_processing_enabled) {
schedule_son_processing();
}
else
{
const fc::time_point now_fine = fc::time_point::now();
const fc::time_point_sec now = now_fine + fc::microseconds( 500000 );
if( plugin.database().get_slot_time(1) >= now )
{
son_processing_enabled = true;
schedule_son_processing();
}
}
} else {
first_block_skipped = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ void sidechain_net_handler::on_applied_block(const signed_block &b) {
const bool is_tracked_asset =
((sidechain == sidechain_type::bitcoin) && (transfer_op.amount.asset_id == gpo.parameters.btc_asset())) ||
((sidechain == sidechain_type::ethereum) && (transfer_op.amount.asset_id == gpo.parameters.eth_asset())) ||
((sidechain == sidechain_type::ethereum) && (transfer_op.amount.asset_id != gpo.parameters.btc_asset()) && (transfer_op.amount.asset_id != gpo.parameters.hbd_asset()) && (transfer_op.amount.asset_id != gpo.parameters.hive_asset())) ||
((sidechain == sidechain_type::ethereum) && (transfer_op.amount.asset_id != gpo.parameters.btc_asset()) && (transfer_op.amount.asset_id != gpo.parameters.hbd_asset()) && (transfer_op.amount.asset_id != gpo.parameters.hive_asset()) && (transfer_op.amount.asset_id != asset_id_type())) ||
((sidechain == sidechain_type::hive) && (transfer_op.amount.asset_id == gpo.parameters.hbd_asset())) ||
((sidechain == sidechain_type::hive) && (transfer_op.amount.asset_id == gpo.parameters.hive_asset()));

Expand Down
2 changes: 1 addition & 1 deletion tests/cli/son.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class son_test_helper
{
fixture_.init_nathan();
fixture_.generate_blocks(HARDFORK_SON_FOR_ETHEREUM_TIME);
fixture_.generate_block();
fixture_.generate_maintenance_block();
}

void create_son(const std::string& account_name, const std::string& son_url,
Expand Down

0 comments on commit aa099f9

Please sign in to comment.