Skip to content

Commit

Permalink
Merge pull request #2104 from bitshares/pr-2103-supply-fix
Browse files Browse the repository at this point in the history
Fix supply issue
  • Loading branch information
abitmore authored Apr 3, 2020
2 parents d0ed212 + 0ff68ee commit eba093c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
21 changes: 21 additions & 0 deletions libraries/chain/db_maint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

#include <graphene/chain/account_object.hpp>
#include <graphene/chain/asset_object.hpp>
#include <graphene/chain/balance_object.hpp>
#include <graphene/chain/budget_record_object.hpp>
#include <graphene/chain/buyback_object.hpp>
#include <graphene/chain/chain_property_object.hpp>
Expand Down Expand Up @@ -970,6 +971,22 @@ void process_hf_1465( database& db )
}
}

/****
* @brief a one-time data process to correct current_supply of BTS token in the BitShares mainnet
*/
void process_hf_2103( database& db )
{
const balance_object* bal = db.find( balance_id_type( HARDFORK_CORE_2103_BALANCE_ID ) );
if( bal != nullptr && bal->balance.amount < 0 )
{
const asset_dynamic_data_object& ddo = bal->balance.asset_id(db).dynamic_data(db);
db.modify<asset_dynamic_data_object>( ddo, [bal](asset_dynamic_data_object& obj) {
obj.current_supply -= bal->balance.amount;
});
db.remove( *bal );
}
}

void update_median_feeds(database& db)
{
time_point_sec head_time = db.head_block_time();
Expand Down Expand Up @@ -1227,6 +1244,10 @@ void database::perform_chain_maintenance(const signed_block& next_block, const g
if ( dgpo.next_maintenance_time <= HARDFORK_CORE_1465_TIME && next_maintenance_time > HARDFORK_CORE_1465_TIME )
process_hf_1465(*this);

// Fix supply issue
if ( dgpo.next_maintenance_time <= HARDFORK_CORE_2103_TIME && next_maintenance_time > HARDFORK_CORE_2103_TIME )
process_hf_2103(*this);

modify(dgpo, [next_maintenance_time](dynamic_global_property_object& d) {
d.next_maintenance_time = next_maintenance_time;
d.accounts_registered_this_interval = 0;
Expand Down
5 changes: 5 additions & 0 deletions libraries/chain/hardfork.d/CORE_2103.hf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// bitshares-core issue #2103 250M BTS supply
#ifndef HARDFORK_CORE_2103_TIME
#define HARDFORK_CORE_2103_TIME (fc::time_point_sec( 1600000000 ) ) // Sep 2020
#define HARDFORK_CORE_2103_BALANCE_ID 56720 // 1.15.56720
#endif
2 changes: 1 addition & 1 deletion programs/build_helpers/cat-parts.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ file( MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/include/graphene/chain/" )

set( HARDFORK_REGENERATE TRUE )

file( GLOB HARDFORKS "${CMAKE_CURRENT_SOURCE_DIR}/hardfork.d/*" )
file( GLOB HARDFORKS "${CMAKE_CURRENT_SOURCE_DIR}/hardfork.d/*.hf" )
foreach( HF ${HARDFORKS} )
file( READ "${HF}" INCL )
string( CONCAT HARDFORK_CONTENT ${HARDFORK_CONTENT} ${INCL} )
Expand Down

0 comments on commit eba093c

Please sign in to comment.