Skip to content

Commit

Permalink
Merge pull request #1213 from oxarbitrage/issue1139
Browse files Browse the repository at this point in the history
remove not needed budget_record_object creation from maint
  • Loading branch information
abitmore committed Sep 5, 2018
2 parents 2997d02 + e7c95b3 commit 2a175e6
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 115 deletions.
2 changes: 0 additions & 2 deletions libraries/chain/db_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include <graphene/chain/asset_object.hpp>
#include <graphene/chain/balance_object.hpp>
#include <graphene/chain/block_summary_object.hpp>
#include <graphene/chain/budget_record_object.hpp>
#include <graphene/chain/buyback_object.hpp>
#include <graphene/chain/chain_property_object.hpp>
#include <graphene/chain/committee_member_object.hpp>
Expand Down Expand Up @@ -214,7 +213,6 @@ void database::initialize_indexes()
add_index< primary_index<simple_index<block_summary_object >> >();
add_index< primary_index<simple_index<chain_property_object > > >();
add_index< primary_index<simple_index<witness_schedule_object > > >();
add_index< primary_index<simple_index<budget_record_object > > >();
add_index< primary_index< special_authority_index > >();
add_index< primary_index< buyback_index > >();
add_index< primary_index<collateral_bid_index > >();
Expand Down
34 changes: 27 additions & 7 deletions libraries/chain/db_maint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@

#include <graphene/chain/account_object.hpp>
#include <graphene/chain/asset_object.hpp>
#include <graphene/chain/budget_record_object.hpp>
#include <graphene/chain/buyback_object.hpp>
#include <graphene/chain/chain_property_object.hpp>
#include <graphene/chain/committee_member_object.hpp>
Expand Down Expand Up @@ -132,6 +131,33 @@ struct worker_pay_visitor
}
};

/// @brief A budget record struct to be used in initialize_budget_record and process_budget
struct budget_record
{
uint64_t time_since_last_budget = 0;

// sources of budget
share_type from_initial_reserve = 0;
share_type from_accumulated_fees = 0;
share_type from_unused_witness_budget = 0;

// witness budget requested by the committee
share_type requested_witness_budget = 0;

// funds that can be released from reserve at maximum rate
share_type total_budget = 0;

// sinks of budget, should sum up to total_budget
share_type witness_budget = 0;
share_type worker_budget = 0;

// unused budget
share_type leftover_worker_funds = 0;

// change in supply due to budget operations
share_type supply_delta = 0;
};

void database::update_worker_votes()
{
const auto& idx = get_index_type<worker_index>().indices().get<by_account>();
Expand Down Expand Up @@ -534,12 +560,6 @@ void database::process_budget()
_dpo.last_budget_time = now;
});

create< budget_record_object >( [&]( budget_record_object& _rec )
{
_rec.time = head_block_time();
_rec.record = rec;
});

// available_funds is money we could spend, but don't want to.
// we simply let it evaporate back into the reserve.
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/db_notify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ void get_relevant_accounts( const object* obj, flat_set<account_id_type>& accoun
break;
case impl_witness_schedule_object_type:
break;
case impl_budget_record_object_type:
case impl_reserved1_object_type:
break;
case impl_special_authority_object_type:
break;
Expand Down
90 changes: 0 additions & 90 deletions libraries/chain/include/graphene/chain/budget_record_object.hpp

This file was deleted.

7 changes: 2 additions & 5 deletions libraries/chain/include/graphene/chain/protocol/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ namespace graphene { namespace chain {
impl_blinded_balance_object_type,
impl_chain_property_object_type,
impl_witness_schedule_object_type,
impl_budget_record_object_type,
impl_reserved1_object_type, // formerly impl_budget_record_object_type, TODO: delete me
impl_special_authority_object_type,
impl_buyback_object_type,
impl_fba_accumulator_object_type,
Expand Down Expand Up @@ -210,7 +210,6 @@ namespace graphene { namespace chain {
class account_transaction_history_object;
class chain_property_object;
class witness_schedule_object;
class budget_record_object;
class special_authority_object;
class buyback_object;
class fba_accumulator_object;
Expand All @@ -230,7 +229,6 @@ namespace graphene { namespace chain {
account_transaction_history_object> account_transaction_history_id_type;
typedef object_id< implementation_ids, impl_chain_property_object_type, chain_property_object> chain_property_id_type;
typedef object_id< implementation_ids, impl_witness_schedule_object_type, witness_schedule_object> witness_schedule_id_type;
typedef object_id< implementation_ids, impl_budget_record_object_type, budget_record_object > budget_record_id_type;
typedef object_id< implementation_ids, impl_blinded_balance_object_type, blinded_balance_object > blinded_balance_id_type;
typedef object_id< implementation_ids, impl_special_authority_object_type, special_authority_object > special_authority_id_type;
typedef object_id< implementation_ids, impl_buyback_object_type, buyback_object > buyback_id_type;
Expand Down Expand Up @@ -361,7 +359,7 @@ FC_REFLECT_ENUM( graphene::chain::impl_object_type,
(impl_blinded_balance_object_type)
(impl_chain_property_object_type)
(impl_witness_schedule_object_type)
(impl_budget_record_object_type)
(impl_reserved1_object_type)
(impl_special_authority_object_type)
(impl_buyback_object_type)
(impl_fba_accumulator_object_type)
Expand Down Expand Up @@ -393,7 +391,6 @@ FC_REFLECT_TYPENAME( graphene::chain::account_statistics_id_type )
FC_REFLECT_TYPENAME( graphene::chain::transaction_obj_id_type )
FC_REFLECT_TYPENAME( graphene::chain::block_summary_id_type )
FC_REFLECT_TYPENAME( graphene::chain::account_transaction_history_id_type )
FC_REFLECT_TYPENAME( graphene::chain::budget_record_id_type )
FC_REFLECT_TYPENAME( graphene::chain::special_authority_id_type )
FC_REFLECT_TYPENAME( graphene::chain::buyback_id_type )
FC_REFLECT_TYPENAME( graphene::chain::fba_accumulator_id_type )
Expand Down
1 change: 0 additions & 1 deletion tests/tests/bitasset_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include <graphene/chain/hardfork.hpp>

#include <graphene/chain/balance_object.hpp>
#include <graphene/chain/budget_record_object.hpp>
#include <graphene/chain/committee_member_object.hpp>
#include <graphene/chain/market_object.hpp>
#include <graphene/chain/withdraw_permission_object.hpp>
Expand Down
9 changes: 0 additions & 9 deletions tests/tests/operation_tests2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include <graphene/chain/hardfork.hpp>

#include <graphene/chain/balance_object.hpp>
#include <graphene/chain/budget_record_object.hpp>
#include <graphene/chain/committee_member_object.hpp>
#include <graphene/chain/market_object.hpp>
#include <graphene/chain/withdraw_permission_object.hpp>
Expand Down Expand Up @@ -2149,14 +2148,6 @@ BOOST_AUTO_TEST_CASE(zero_second_vbo)
BOOST_CHECK( vbid(db).get_allowed_withdraw(db.head_block_time()) == asset(0) );
generate_block();
BOOST_CHECK( vbid(db).get_allowed_withdraw(db.head_block_time()) == asset(10000) );

/*
db.get_index_type< simple_index<budget_record_object> >().inspect_all_objects(
[&](const object& o)
{
ilog( "budget: ${brec}", ("brec", static_cast<const budget_record_object&>(o)) );
});
*/
}
} FC_LOG_AND_RETHROW()
}
Expand Down

0 comments on commit 2a175e6

Please sign in to comment.