diff --git a/libraries/chain/db_maint.cpp b/libraries/chain/db_maint.cpp index b768460a..89fae5ca 100644 --- a/libraries/chain/db_maint.cpp +++ b/libraries/chain/db_maint.cpp @@ -764,9 +764,9 @@ void schedule_pending_dividend_balances(database& db, #ifdef USE_VESTING_OBJECT_BY_ASSET_BALANCE_INDEX // get only once a collection of accounts that hold nonzero vesting balances of the dividend asset auto vesting_balances_begin = - vesting_index.indices().get().lower_bound(boost::make_tuple(dividend_holder_asset_obj.id)); + vesting_index.indices().get().lower_bound(boost::make_tuple(dividend_holder_asset_obj.id, vesting_balance_type::unspecified)); auto vesting_balances_end = - vesting_index.indices().get().upper_bound(boost::make_tuple(dividend_holder_asset_obj.id, share_type())); + vesting_index.indices().get().upper_bound(boost::make_tuple(dividend_holder_asset_obj.id, vesting_balance_type::unspecified, share_type())); for (const vesting_balance_object& vesting_balance_obj : boost::make_iterator_range(vesting_balances_begin, vesting_balances_end)) { vesting_amounts[vesting_balance_obj.owner] += vesting_balance_obj.balance.amount; @@ -1247,9 +1247,9 @@ void database::perform_chain_maintenance(const signed_block& next_block, const g const vesting_balance_index& vesting_index = d.get_index_type(); #ifdef USE_VESTING_OBJECT_BY_ASSET_BALANCE_INDEX auto vesting_balances_begin = - vesting_index.indices().get().lower_bound(boost::make_tuple(asset_id_type())); + vesting_index.indices().get().lower_bound(boost::make_tuple(asset_id_type(), vesting_balance_type::unspecified)); auto vesting_balances_end = - vesting_index.indices().get().upper_bound(boost::make_tuple(asset_id_type(), share_type())); + vesting_index.indices().get().upper_bound(boost::make_tuple(asset_id_type(), vesting_balance_type::unspecified, share_type())); for (const vesting_balance_object& vesting_balance_obj : boost::make_iterator_range(vesting_balances_begin, vesting_balances_end)) { vesting_amounts[vesting_balance_obj.owner] += vesting_balance_obj.balance.amount; diff --git a/libraries/chain/include/graphene/chain/protocol/vesting.hpp b/libraries/chain/include/graphene/chain/protocol/vesting.hpp index 4915b62e..5a78fd65 100644 --- a/libraries/chain/include/graphene/chain/protocol/vesting.hpp +++ b/libraries/chain/include/graphene/chain/protocol/vesting.hpp @@ -24,7 +24,9 @@ #pragma once #include -namespace graphene { namespace chain { +namespace graphene { namespace chain { + + enum class vesting_balance_type { unspecified, gpos }; struct linear_vesting_policy_initializer { @@ -72,6 +74,7 @@ namespace graphene { namespace chain { account_id_type owner; ///< Who is able to withdraw the balance asset amount; vesting_policy_initializer policy; + vesting_balance_type balance_type; account_id_type fee_payer()const { return creator; } void validate()const @@ -112,9 +115,11 @@ namespace graphene { namespace chain { FC_REFLECT( graphene::chain::vesting_balance_create_operation::fee_parameters_type, (fee) ) FC_REFLECT( graphene::chain::vesting_balance_withdraw_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::vesting_balance_create_operation, (fee)(creator)(owner)(amount)(policy) ) +FC_REFLECT( graphene::chain::vesting_balance_create_operation, (fee)(creator)(owner)(amount)(policy)(balance_type) ) FC_REFLECT( graphene::chain::vesting_balance_withdraw_operation, (fee)(vesting_balance)(owner)(amount) ) FC_REFLECT(graphene::chain::linear_vesting_policy_initializer, (begin_timestamp)(vesting_cliff_seconds)(vesting_duration_seconds) ) FC_REFLECT(graphene::chain::cdd_vesting_policy_initializer, (start_claim)(vesting_seconds) ) FC_REFLECT_TYPENAME( graphene::chain::vesting_policy_initializer ) + +FC_REFLECT_ENUM( graphene::chain::vesting_balance_type, (unspecified)(gpos) ) diff --git a/libraries/chain/include/graphene/chain/vesting_balance_object.hpp b/libraries/chain/include/graphene/chain/vesting_balance_object.hpp index dc2fe18c..6e0bd689 100644 --- a/libraries/chain/include/graphene/chain/vesting_balance_object.hpp +++ b/libraries/chain/include/graphene/chain/vesting_balance_object.hpp @@ -24,6 +24,8 @@ #pragma once #include +#include + #include #include @@ -143,6 +145,9 @@ namespace graphene { namespace chain { /// The vesting policy stores details on when funds vest, and controls when they may be withdrawn vesting_policy policy; + /// We can have 2 types of vesting, gpos and all the rest + vesting_balance_type balance_type = vesting_balance_type::unspecified; + vesting_balance_object() {} ///@brief Deposit amount into vesting balance, requiring it to vest before withdrawal @@ -185,12 +190,14 @@ namespace graphene { namespace chain { composite_key< vesting_balance_object, member_offset, + member, member_offset //member //member_offset >, composite_key_compare< std::less< asset_id_type >, + std::less< vesting_balance_type >, std::greater< share_type > //std::less< account_id_type > > @@ -224,4 +231,5 @@ FC_REFLECT_DERIVED(graphene::chain::vesting_balance_object, (graphene::db::objec (owner) (balance) (policy) + (balance_type) ) diff --git a/libraries/chain/vesting_balance_evaluator.cpp b/libraries/chain/vesting_balance_evaluator.cpp index ee918fd1..59967d30 100644 --- a/libraries/chain/vesting_balance_evaluator.cpp +++ b/libraries/chain/vesting_balance_evaluator.cpp @@ -93,6 +93,7 @@ object_id_type vesting_balance_create_evaluator::do_apply( const vesting_balance obj.owner = op.owner; obj.balance = op.amount; op.policy.visit( init_policy_visitor( obj.policy, op.amount.amount, now ) ); + obj.balance_type = op.balance_type; } );