From b06e1d680a0d2ba042671331020481f44c94ee0e Mon Sep 17 00:00:00 2001 From: Srdjan Obucina Date: Fri, 17 Jan 2020 21:32:44 +0100 Subject: [PATCH] Create son_wallet_object on new set of SONs, to initiate primary wallet recreation --- libraries/chain/db_maint.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/libraries/chain/db_maint.cpp b/libraries/chain/db_maint.cpp index 7b111fd4..7e3d8615 100644 --- a/libraries/chain/db_maint.cpp +++ b/libraries/chain/db_maint.cpp @@ -470,7 +470,22 @@ void database::update_active_sons() ilog( "Active SONs set NOT CHANGED" ); } else { ilog( "Active SONs set CHANGED" ); - // Store new SON info, initiate wallet recreation and transfer of funds + + // Expire for current son_wallet_object wallet, if exists + const auto& idx = get_index_type().indices().get(); + auto obj = idx.rbegin(); + if (obj != idx.rend()) { + modify(*obj, [&, &obj](son_wallet_object &swo) { + swo.expires = head_block_time(); + }); + } + + // Create new son_wallet_object, to initiate wallet recreation + const auto& new_son_wallet_object = create( [&]( son_wallet_object& obj ){ + obj.valid_from = head_block_time(); + obj.expires = time_point_sec::maximum(); + obj.sons.insert(obj.sons.end(), new_active_sons.begin(), new_active_sons.end()); + }); } modify(gpo, [&]( global_property_object& gp ){