forked from lthn/blockchain
added balance() and rpc api implementations for multi_assets versions
This commit is contained in:
parent
65eea67b30
commit
1c76d0d325
4 changed files with 15 additions and 10 deletions
|
|
@ -3009,7 +3009,7 @@ uint64_t wallet2::balance(uint64_t& unlocked, uint64_t& awaiting_in, uint64_t& a
|
|||
awaiting_in = 0;
|
||||
awaiting_out = 0;
|
||||
mined = 0;
|
||||
std::unordered_map<crypto::hash, asset_balance_entry_base> balances;
|
||||
std::unordered_map<crypto::hash, wallet_public::asset_balance_entry_base> balances;
|
||||
balance(balances, mined);
|
||||
auto it = balances.find(currency::null_hash);
|
||||
if (it != balances.end())
|
||||
|
|
@ -3022,7 +3022,7 @@ uint64_t wallet2::balance(uint64_t& unlocked, uint64_t& awaiting_in, uint64_t& a
|
|||
return total;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
bool wallet2::balance(std::unordered_map<crypto::hash, asset_balance_entry_base>& balances, uint64_t& mined) const
|
||||
bool wallet2::balance(std::unordered_map<crypto::hash, wallet_public::asset_balance_entry_base>& balances, uint64_t& mined) const
|
||||
{
|
||||
mined = 0;
|
||||
|
||||
|
|
@ -3030,7 +3030,7 @@ bool wallet2::balance(std::unordered_map<crypto::hash, asset_balance_entry_base>
|
|||
{
|
||||
if (td.is_spendable() || (td.is_reserved_for_escrow() && !td.is_spent()))
|
||||
{
|
||||
asset_balance_entry_base& e = balances[td.get_asset_id()];
|
||||
wallet_public::asset_balance_entry_base& e = balances[td.get_asset_id()];
|
||||
e.total += td.amount();
|
||||
if (is_transfer_unlocked(td))
|
||||
e.unlocked += td.amount();
|
||||
|
|
@ -3041,7 +3041,7 @@ bool wallet2::balance(std::unordered_map<crypto::hash, asset_balance_entry_base>
|
|||
|
||||
for(auto& utx : m_unconfirmed_txs)
|
||||
{
|
||||
asset_balance_entry_base& e = balances[utx.asset_id];
|
||||
wallet_public::asset_balance_entry_base& e = balances[utx.second.asset_id];
|
||||
if (utx.second.is_income)
|
||||
{
|
||||
e.total += utx.second.amount;
|
||||
|
|
|
|||
|
|
@ -597,7 +597,7 @@ namespace tools
|
|||
std::shared_ptr<i_core_proxy> get_core_proxy();
|
||||
uint64_t balance() const;
|
||||
uint64_t balance(uint64_t& unloked, uint64_t& awaiting_in, uint64_t& awaiting_out, uint64_t& mined) const;
|
||||
bool balance(std::unordered_map<crypto::hash, asset_balance_entry_base>& balances, uint64_t& mined) const;
|
||||
bool balance(std::unordered_map<crypto::hash, wallet_public::asset_balance_entry_base>& balances, uint64_t& mined) const;
|
||||
uint64_t balance(uint64_t& unloked) const;
|
||||
|
||||
uint64_t unlocked_balance() const;
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ namespace tools
|
|||
res.balance = m_wallet.balance();
|
||||
res.unlocked_balance = m_wallet.unlocked_balance();
|
||||
uint64_t mined = 0;
|
||||
std::unordered_map<crypto::hash, asset_balance_entry_base> balances;
|
||||
std::unordered_map<crypto::hash, wallet_public::asset_balance_entry_base> balances;
|
||||
m_wallet.balance(balances, mined);
|
||||
auto it = balances.find(currency::null_hash);
|
||||
if (it != balances.end())
|
||||
|
|
@ -200,7 +200,7 @@ namespace tools
|
|||
for (auto el : balances)
|
||||
{
|
||||
res.balances.push_back(wallet_public::asset_balance_entry());
|
||||
res.balances.back() = el.second;
|
||||
static_cast<wallet_public::asset_balance_entry_base&>(res.balances.back()) = el.second;
|
||||
res.balances.back().asset_id = el.first;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ namespace
|
|||
const command_line::arg_descriptor<bool> arg_test_transactions ("test-transactions", "");
|
||||
const command_line::arg_descriptor<std::string> arg_run_single_test ("run-single-test", "" );
|
||||
const command_line::arg_descriptor<bool> arg_enable_debug_asserts ("enable-debug-asserts", "" );
|
||||
const command_line::arg_descriptor<bool> arg_stop_on_fail ("stop-on-fail", "");
|
||||
|
||||
boost::program_options::variables_map g_vm;
|
||||
}
|
||||
|
|
@ -671,13 +672,14 @@ int main(int argc, char* argv[])
|
|||
command_line::add_arg(desc_options, arg_test_transactions);
|
||||
command_line::add_arg(desc_options, arg_run_single_test);
|
||||
command_line::add_arg(desc_options, arg_enable_debug_asserts);
|
||||
command_line::add_arg(desc_options, arg_stop_on_fail);
|
||||
command_line::add_arg(desc_options, command_line::arg_data_dir, std::string("."));
|
||||
command_line::add_arg(desc_options, command_line::arg_stop_after_height);
|
||||
command_line::add_arg(desc_options, command_line::arg_disable_ntp);
|
||||
|
||||
currency::core::init_options(desc_options);
|
||||
tools::db::db_backend_selector::init_options(desc_options);
|
||||
|
||||
bool stop_on_first_fail = false;
|
||||
bool r = command_line::handle_error_helper(desc_options, [&]()
|
||||
{
|
||||
po::store(po::parse_command_line(argc, argv, desc_options), g_vm);
|
||||
|
|
@ -693,6 +695,11 @@ int main(int argc, char* argv[])
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (command_line::has_arg(g_vm, arg_stop_on_fail))
|
||||
{
|
||||
stop_on_first_fail = command_line::get_arg(g_vm, arg_stop_on_fail);
|
||||
}
|
||||
|
||||
size_t tests_count = 0;
|
||||
size_t serious_failures_count = 0;
|
||||
std::set<std::string> failed_tests;
|
||||
|
|
@ -756,8 +763,6 @@ int main(int argc, char* argv[])
|
|||
|
||||
#undef MARK_TEST_AS_POSTPONED
|
||||
|
||||
bool stop_on_first_fail = false;
|
||||
|
||||
|
||||
// TODO // GENERATE_AND_PLAY(wallet_spend_form_auditable_and_track);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue