2015-06-08 15:50:35 +00:00
|
|
|
/*
|
2015-10-12 17:48:40 +00:00
|
|
|
* Copyright (c) 2015 Cryptonomex, Inc., and contributors.
|
|
|
|
|
*
|
2016-01-06 09:51:18 +00:00
|
|
|
* The MIT License
|
2015-10-12 17:48:40 +00:00
|
|
|
*
|
2016-01-06 09:51:18 +00:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
|
* furnished to do so, subject to the following conditions:
|
2015-10-12 17:48:40 +00:00
|
|
|
*
|
2016-01-06 09:51:18 +00:00
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
|
* all copies or substantial portions of the Software.
|
2015-10-12 17:02:59 +00:00
|
|
|
*
|
2016-01-06 09:51:18 +00:00
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
|
* THE SOFTWARE.
|
2015-06-08 15:50:35 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <graphene/chain/database.hpp>
|
|
|
|
|
|
|
|
|
|
#include <graphene/chain/account_object.hpp>
|
|
|
|
|
#include <graphene/chain/asset_object.hpp>
|
2015-07-08 20:39:23 +00:00
|
|
|
#include <graphene/chain/market_evaluator.hpp>
|
2015-06-08 15:50:35 +00:00
|
|
|
#include <graphene/chain/vesting_balance_object.hpp>
|
|
|
|
|
#include <graphene/chain/witness_object.hpp>
|
|
|
|
|
|
|
|
|
|
namespace graphene { namespace chain {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This method dumps the state of the blockchain in a semi-human readable form for the
|
|
|
|
|
* purpose of tracking down funds and mismatches in currency allocation
|
|
|
|
|
*/
|
|
|
|
|
void database::debug_dump()
|
|
|
|
|
{
|
|
|
|
|
const auto& db = *this;
|
|
|
|
|
const asset_dynamic_data_object& core_asset_data = db.get_core_asset().dynamic_asset_data_id(db);
|
|
|
|
|
|
|
|
|
|
const auto& balance_index = db.get_index_type<account_balance_index>().indices();
|
|
|
|
|
const simple_index<account_statistics_object>& statistics_index = db.get_index_type<simple_index<account_statistics_object>>();
|
|
|
|
|
map<asset_id_type,share_type> total_balances;
|
|
|
|
|
map<asset_id_type,share_type> total_debts;
|
|
|
|
|
share_type core_in_orders;
|
|
|
|
|
share_type reported_core_in_orders;
|
|
|
|
|
|
|
|
|
|
for( const account_balance_object& a : balance_index )
|
|
|
|
|
{
|
2015-09-30 22:30:44 +00:00
|
|
|
// idump(("balance")(a));
|
2015-06-08 15:50:35 +00:00
|
|
|
total_balances[a.asset_type] += a.balance;
|
|
|
|
|
}
|
|
|
|
|
for( const account_statistics_object& s : statistics_index )
|
|
|
|
|
{
|
2015-09-30 22:30:44 +00:00
|
|
|
// idump(("statistics")(s));
|
2015-06-08 15:50:35 +00:00
|
|
|
reported_core_in_orders += s.total_core_in_orders;
|
|
|
|
|
}
|
|
|
|
|
for( const limit_order_object& o : db.get_index_type<limit_order_index>().indices() )
|
|
|
|
|
{
|
2015-10-02 13:23:03 +00:00
|
|
|
// idump(("limit_order")(o));
|
2015-06-08 15:50:35 +00:00
|
|
|
auto for_sale = o.amount_for_sale();
|
|
|
|
|
if( for_sale.asset_id == asset_id_type() ) core_in_orders += for_sale.amount;
|
|
|
|
|
total_balances[for_sale.asset_id] += for_sale.amount;
|
|
|
|
|
}
|
|
|
|
|
for( const call_order_object& o : db.get_index_type<call_order_index>().indices() )
|
|
|
|
|
{
|
2015-10-02 13:23:03 +00:00
|
|
|
// idump(("call_order")(o));
|
2015-06-08 15:50:35 +00:00
|
|
|
auto col = o.get_collateral();
|
|
|
|
|
if( col.asset_id == asset_id_type() ) core_in_orders += col.amount;
|
|
|
|
|
total_balances[col.asset_id] += col.amount;
|
|
|
|
|
total_debts[o.get_debt().asset_id] += o.get_debt().amount;
|
|
|
|
|
}
|
|
|
|
|
for( const asset_object& asset_obj : db.get_index_type<asset_index>().indices() )
|
|
|
|
|
{
|
|
|
|
|
total_balances[asset_obj.id] += asset_obj.dynamic_asset_data_id(db).accumulated_fees;
|
|
|
|
|
total_balances[asset_id_type()] += asset_obj.dynamic_asset_data_id(db).fee_pool;
|
2015-09-30 22:30:44 +00:00
|
|
|
// edump((total_balances[asset_obj.id])(asset_obj.dynamic_asset_data_id(db).current_supply ) );
|
2015-06-08 15:50:35 +00:00
|
|
|
}
|
2015-09-30 22:30:44 +00:00
|
|
|
|
2015-06-08 15:50:35 +00:00
|
|
|
if( total_balances[asset_id_type()].value != core_asset_data.current_supply.value )
|
|
|
|
|
{
|
|
|
|
|
edump( (total_balances[asset_id_type()].value)(core_asset_data.current_supply.value ));
|
|
|
|
|
}
|
2015-07-01 22:17:49 +00:00
|
|
|
|
2015-09-30 22:30:44 +00:00
|
|
|
|
|
|
|
|
/*
|
2015-07-01 22:17:49 +00:00
|
|
|
const auto& vbidx = db.get_index_type<simple_index<vesting_balance_object>>();
|
|
|
|
|
for( const auto& s : vbidx )
|
2015-07-05 21:58:24 +00:00
|
|
|
{
|
2015-09-30 22:30:44 +00:00
|
|
|
// idump(("vesting_balance")(s));
|
2015-07-05 21:58:24 +00:00
|
|
|
}
|
2015-09-30 22:30:44 +00:00
|
|
|
*/
|
2015-06-08 15:50:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} }
|