Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use special container type for token balances #2074

Open
wants to merge 59 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
392e041
Added stored_value class
pmconrad Nov 22, 2019
cb9ae90
Minor refactoring of undo
pmconrad Nov 22, 2019
0cbfeb5
Intermediate
pmconrad Nov 29, 2019
b03cccc
Intermediate
pmconrad Nov 29, 2019
a6e75fa
Intermediate
pmconrad Nov 30, 2019
b80b1f1
Intermediate
pmconrad Dec 1, 2019
1097021
Intermediate
pmconrad Dec 2, 2019
e7cec9a
Intermediate
pmconrad Dec 2, 2019
a857972
Intermediate
pmconrad Dec 2, 2019
162c33b
Fixups
pmconrad Dec 2, 2019
2e3e695
Fixup serialization
pmconrad Dec 3, 2019
13ffb21
Fix plugins
pmconrad Dec 3, 2019
f0a6542
Compiles without tests
pmconrad Dec 3, 2019
6c32c85
Tests compile but crash horribly
pmconrad Dec 4, 2019
25f3f67
Fixup modify
pmconrad Dec 5, 2019
c655684
Implement clear(), fix backup/restore
pmconrad Dec 5, 2019
2a0a918
Refactored duplicate code into common method
pmconrad Dec 6, 2019
88b3371
Removed unused annotated_object
pmconrad Dec 6, 2019
b988d16
Fixed undo
pmconrad Dec 6, 2019
53171e3
Allow non-zero balance during exception handling (assume stack is bei…
pmconrad Dec 6, 2019
c728899
Fixups
pmconrad Dec 10, 2019
6a7ce5f
fixup object::restore
pmconrad Dec 10, 2019
c07fb09
Fixup balance claim
pmconrad Dec 10, 2019
e5127fe
fixup recreate
pmconrad Dec 10, 2019
25737ff
Fixed initial testing balance
pmconrad Dec 10, 2019
1ecb744
Fixup call_order backup
pmconrad Dec 12, 2019
b956066
Fixup asset object initialization
pmconrad Dec 12, 2019
2b29486
Fixup call_order_update evaluator
pmconrad Dec 12, 2019
6cc0823
Fixup order matching
pmconrad Dec 12, 2019
9cb376f
Fixup stored_value
pmconrad Dec 13, 2019
f5b10f5
Fix confidential fee handling
pmconrad Dec 13, 2019
1ecffe2
Fix fee height check
pmconrad Dec 13, 2019
4ce6cb6
Fixed object notification
pmconrad Dec 14, 2019
3ad63f5
Avoid _undo_db operating on unregistered indexes
pmconrad Dec 15, 2019
eb33f53
Fixup fixture
pmconrad Dec 15, 2019
6baa6ad
Fixed deferred_paid_fee handling
pmconrad Dec 16, 2019
6a284be
Fix budget calculation
pmconrad Dec 16, 2019
f53f8cd
Fixed expected block number due to change in fixture
pmconrad Dec 16, 2019
620a02f
Revert "Avoid _undo_db operating on unregistered indexes"
pmconrad Dec 16, 2019
8f182a4
Fix op history test expectations wrt balance_claim in fixture
pmconrad Dec 16, 2019
18006c3
Fixup total core in orders
pmconrad Dec 16, 2019
bd5ffa1
Dont update call_price if no collateral is left
pmconrad Dec 17, 2019
8452498
Fixup force settlement evaluator
pmconrad Dec 17, 2019
ed988f4
Fixup worker payout
pmconrad Dec 17, 2019
254bde9
Fixup force_settle_backup
pmconrad Dec 17, 2019
130086e
Fix tests
pmconrad Dec 17, 2019
da29b6e
Object serialization fixes
pmconrad Dec 19, 2019
09bfbfc
Resolve API incompatibilities
pmconrad Dec 19, 2019
494d686
fixup test
pmconrad Dec 19, 2019
a971dd1
Fixup wallet
pmconrad Dec 20, 2019
30c2a19
Add workaround for -250M genesis balance
pmconrad Dec 24, 2019
860e4b7
Generalized solution for the fee problem
pmconrad Dec 24, 2019
6955f27
Always borrow fee for limit_order_create
pmconrad Dec 25, 2019
6e3b78b
Fixup asset_dynamic_data init
pmconrad Dec 25, 2019
1edceb7
Fixup hf_429 handling
pmconrad Dec 25, 2019
833c834
Fixup asset_dynamic_data init
pmconrad Dec 25, 2019
5f65464
Always borrow fee but without dyn_data
pmconrad Dec 25, 2019
3d189bd
Revert dyn_data.borrowed_fees
pmconrad Dec 26, 2019
42bed75
Fix settlement_fund asset_id after backing asset change
pmconrad Dec 26, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions libraries/app/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ namespace graphene { namespace app {
if( result.size() >= limit )
break;

if( bal.balance.value == 0 )
if( bal.balance.get_amount() == 0 )
continue;

if( index++ < start )
Expand All @@ -603,7 +603,7 @@ namespace graphene { namespace app {
account_asset_balance aab;
aab.name = account->name;
aab.account_id = account->id;
aab.amount = bal.balance.value;
aab.amount = bal.balance.get_amount();

result.push_back(aab);
}
Expand Down
44 changes: 44 additions & 0 deletions libraries/app/api_objects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,47 @@ market_ticker::market_ticker(const fc::time_point_sec& now,
}

} } // graphene::app

FC_REFLECT_DERIVED_NO_TYPENAME( graphene::app::account_balance_api_object,
(graphene::chain::account_balance_master), (balance) );
FC_REFLECT_DERIVED_NO_TYPENAME( graphene::app::account_statistics_api_object,
(graphene::chain::account_statistics_master),
(pending_fees)(pending_vested_fees) );
FC_REFLECT_DERIVED_NO_TYPENAME( graphene::app::asset_bitasset_data_api_object,
(graphene::chain::asset_bitasset_data_master), (settlement_fund) );
FC_REFLECT_DERIVED_NO_TYPENAME( graphene::app::asset_dynamic_data_api_object,
(graphene::chain::asset_dynamic_data_master),
(current_supply)(confidential_supply)(accumulated_fees)(fee_pool) );
FC_REFLECT_DERIVED_NO_TYPENAME( graphene::app::balance_api_object,
(graphene::chain::balance_master), (balance) );
FC_REFLECT_DERIVED_NO_TYPENAME( graphene::app::fba_accumulator_api_object,
(graphene::chain::fba_accumulator_master), (accumulated_fba_fees) );
FC_REFLECT_DERIVED_NO_TYPENAME( graphene::app::limit_order_api_object,
(graphene::chain::limit_order_master), (for_sale)(deferred_fee)(deferred_paid_fee) );
FC_REFLECT_DERIVED_NO_TYPENAME( graphene::app::call_order_api_object,
(graphene::chain::call_order_master), (debt)(collateral) );
FC_REFLECT_DERIVED_NO_TYPENAME( graphene::app::force_settlement_api_object,
(graphene::chain::force_settlement_master), (balance) );
FC_REFLECT_DERIVED_NO_TYPENAME( graphene::app::collateral_bid_api_object,
(graphene::chain::collateral_bid_master), (inv_swan_price) );
FC_REFLECT_DERIVED_NO_TYPENAME( graphene::app::htlc_api_object::transfer_info,
(graphene::chain::htlc_master::transfer_info_master), (amount)(asset_id) );
FC_REFLECT_DERIVED_NO_TYPENAME( graphene::app::htlc_api_object,
(graphene::chain::htlc_master), (transfer) );
FC_REFLECT_DERIVED_NO_TYPENAME( graphene::app::dynamic_global_property_api_object,
(graphene::chain::dynamic_global_property_master), (witness_budget) );

GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::app::account_balance_api_object )
GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::app::account_statistics_api_object )
GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::app::asset_bitasset_data_api_object )
GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::app::asset_dynamic_data_api_object )
GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::app::balance_api_object )
GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::app::fba_accumulator_api_object )
GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::app::limit_order_api_object )
GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::app::call_order_api_object )
GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::app::force_settlement_api_object )
GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::app::collateral_bid_api_object )
GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::app::htlc_api_object::transfer_info )
GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::app::htlc_api_object )
GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::app::vesting_balance_api_object )
GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::app::dynamic_global_property_api_object )
165 changes: 105 additions & 60 deletions libraries/app/database_api.cpp

Large diffs are not rendered by default.

36 changes: 18 additions & 18 deletions libraries/app/database_api_impl.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class database_api_impl : public std::enable_shared_from_this<database_api_impl>
global_property_object get_global_properties()const;
fc::variant_object get_config()const;
chain_id_type get_chain_id()const;
dynamic_global_property_object get_dynamic_global_properties()const;
const dynamic_global_property_object& get_dynamic_global_properties()const;

// Keys
vector<flat_set<account_id_type>> get_key_references( vector<public_key_type> key )const;
Expand All @@ -84,9 +84,9 @@ class database_api_impl : public std::enable_shared_from_this<database_api_impl>
vector<asset> get_account_balances( const std::string& account_name_or_id,
const flat_set<asset_id_type>& assets )const;
vector<asset> get_named_account_balances(const std::string& name, const flat_set<asset_id_type>& assets)const;
vector<balance_object> get_balance_objects( const vector<address>& addrs )const;
vector<balance_api_object> get_balance_objects( const vector<address>& addrs )const;
vector<asset> get_vested_balances( const vector<balance_id_type>& objs )const;
vector<vesting_balance_object> get_vesting_balances( const std::string account_id_or_name )const;
vector<vesting_balance_api_object> get_vesting_balances( const std::string account_id_or_name )const;

// Assets
uint64_t get_asset_count()const;
Expand All @@ -99,22 +99,22 @@ class database_api_impl : public std::enable_shared_from_this<database_api_impl>
asset_id_type start, uint32_t limit)const;

// Markets / feeds
vector<limit_order_object> get_limit_orders( const std::string& a, const std::string& b,
vector<limit_order_api_object> get_limit_orders( const std::string& a, const std::string& b,
uint32_t limit)const;
vector<limit_order_object> get_account_limit_orders( const string& account_name_or_id,
vector<limit_order_api_object> get_account_limit_orders( const string& account_name_or_id,
const string &base,
const string &quote, uint32_t limit,
optional<limit_order_id_type> ostart_id,
optional<price> ostart_price );
vector<call_order_object> get_call_orders(const std::string& a, uint32_t limit)const;
vector<call_order_object> get_call_orders_by_account(const std::string& account_name_or_id,
vector<call_order_api_object> get_call_orders(const std::string& a, uint32_t limit)const;
vector<call_order_api_object> get_call_orders_by_account(const std::string& account_name_or_id,
asset_id_type start, uint32_t limit)const;
vector<force_settlement_object> get_settle_orders(const std::string& a, uint32_t limit)const;
vector<force_settlement_object> get_settle_orders_by_account(const std::string& account_name_or_id,
vector<force_settlement_api_object> get_settle_orders(const std::string& a, uint32_t limit)const;
vector<force_settlement_api_object> get_settle_orders_by_account(const std::string& account_name_or_id,
force_settlement_id_type start,
uint32_t limit)const;
vector<call_order_object> get_margin_positions( const std::string account_id_or_name )const;
vector<collateral_bid_object> get_collateral_bids( const std::string& asset,
vector<call_order_api_object> get_margin_positions( const std::string account_id_or_name )const;
vector<collateral_bid_api_object> get_collateral_bids( const std::string& asset,
uint32_t limit, uint32_t start)const;

void subscribe_to_market( std::function<void(const variant&)> callback,
Expand Down Expand Up @@ -187,12 +187,12 @@ class database_api_impl : public std::enable_shared_from_this<database_api_impl>
uint32_t limit )const;

// HTLC
optional<htlc_object> get_htlc( htlc_id_type id, optional<bool> subscribe ) const;
vector<htlc_object> get_htlc_by_from( const std::string account_id_or_name,
optional<htlc_api_object> get_htlc( htlc_id_type id, optional<bool> subscribe ) const;
vector<htlc_api_object> get_htlc_by_from( const std::string account_id_or_name,
htlc_id_type start, uint32_t limit ) const;
vector<htlc_object> get_htlc_by_to( const std::string account_id_or_name,
vector<htlc_api_object> get_htlc_by_to( const std::string account_id_or_name,
htlc_id_type start, uint32_t limit) const;
vector<htlc_object> list_htlcs(const htlc_id_type lower_bound_id, uint32_t limit) const;
vector<htlc_api_object> list_htlcs(const htlc_id_type lower_bound_id, uint32_t limit) const;

//private:

Expand Down Expand Up @@ -232,7 +232,7 @@ class database_api_impl : public std::enable_shared_from_this<database_api_impl>
////////////////////////////////////////////////

// helper function
vector<limit_order_object> get_limit_orders( const asset_id_type a, const asset_id_type b,
vector<limit_order_api_object> get_limit_orders( const asset_id_type a, const asset_id_type b,
const uint32_t limit )const;

////////////////////////////////////////////////
Expand Down Expand Up @@ -300,8 +300,8 @@ class database_api_impl : public std::enable_shared_from_this<database_api_impl>
const std::pair<asset_id_type,asset_id_type> get_order_market( const force_settlement_object& order )
{
// TODO cache the result to avoid repeatly fetching from db
asset_id_type backing_id = order.balance.asset_id( _db ).bitasset_data( _db ).options.short_backing_asset;
auto tmp = std::make_pair( order.balance.asset_id, backing_id );
asset_id_type backing_id = order.balance.get_asset()( _db ).bitasset_data( _db ).options.short_backing_asset;
auto tmp = std::make_pair( order.balance.get_asset(), backing_id );
if( tmp.first > tmp.second ) std::swap( tmp.first, tmp.second );
return tmp;
}
Expand Down
Loading