1
0
Fork 0
forked from lthn/blockchain

implemented exclude_staking_txs filter

This commit is contained in:
cryptozoidberg 2020-09-01 00:26:22 +02:00
parent bd894a0119
commit aea993f36b
No known key found for this signature in database
GPG key ID: 22DEB97A54C6FDEC
8 changed files with 47 additions and 22 deletions

View file

@ -1651,7 +1651,7 @@ QString MainWindow::open_wallet(const QString& param)
//return que_call2<view::open_wallet_request>("open_wallet", param, [this](const view::open_wallet_request& owd, view::api_response& ar){
PREPARE_ARG_FROM_JSON(view::open_wallet_request, owd);
PREPARE_RESPONSE(view::open_wallet_response, ar);
ar.error_code = m_backend.open_wallet(epee::string_encoding::utf8_to_wstring(owd.path), owd.pass, owd.txs_to_return, ar.response_data);
ar.error_code = m_backend.open_wallet(epee::string_encoding::utf8_to_wstring(owd.path), owd.pass, owd.txs_to_return, ar.response_data, owd.exclude_mining_txs);
return MAKE_RESPONSE(ar);
CATCH_ENTRY_FAIL_API_RESPONCE();
}
@ -1795,7 +1795,7 @@ QString MainWindow::get_recent_transfers(const QString& param)
LOG_API_TIMING();
PREPARE_ARG_FROM_JSON(view::get_recent_transfers_request, a);
PREPARE_RESPONSE(view::transfers_array, ar);
ar.error_code = m_backend.get_recent_transfers(a.wallet_id, a.offset, a.count, ar.response_data);
ar.error_code = m_backend.get_recent_transfers(a.wallet_id, a.offset, a.count, ar.response_data, a.exclude_mining_txs);
return MAKE_RESPONSE(ar);
CATCH_ENTRY_FAIL_API_RESPONCE();
}

View file

@ -371,11 +371,13 @@ public:
std::vector<tools::wallet_public::wallet_transfer_info> unconfirmed;
std::vector<tools::wallet_public::wallet_transfer_info> history;
uint64_t total_history_items;
uint64_t last_item_index;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(unconfirmed)
KV_SERIALIZE(history)
KV_SERIALIZE(total_history_items)
KV_SERIALIZE(last_item_index)
END_KV_SERIALIZE_MAP()
};
@ -385,11 +387,13 @@ public:
std::string pass;
std::string path;
uint64_t txs_to_return;
bool exclude_mining_txs;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(pass)
KV_SERIALIZE(path)
KV_SERIALIZE(txs_to_return)
KV_SERIALIZE(exclude_mining_txs)
END_KV_SERIALIZE_MAP()
};
@ -398,6 +402,7 @@ public:
uint64_t wallet_id;
uint64_t offset;
uint64_t count;
bool exclude_mining_txs;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(wallet_id)

View file

@ -2948,17 +2948,27 @@ uint64_t wallet2::get_transfer_entries_count()
return m_transfers.size();
}
//----------------------------------------------------------------------------------------------------
void wallet2::get_recent_transfers_history(std::vector<wallet_public::wallet_transfer_info>& trs, size_t offset, size_t count, uint64_t& total)
void wallet2::get_recent_transfers_history(std::vector<wallet_public::wallet_transfer_info>& trs, size_t offset, size_t count, uint64_t& total, uint64_t& last_item_index, bool exclude_mining_txs)
{
if (offset >= m_transfer_history.size())
if (!count || offset >= m_transfer_history.size())
return;
auto start = m_transfer_history.rbegin() + offset;
auto stop = m_transfer_history.size() - offset >= count ? start + count : m_transfer_history.rend();
if (!count)
stop = m_transfer_history.rend();
trs.insert(trs.end(), start, stop);
for (auto it = m_transfer_history.rbegin() + offset; it != m_transfer_history.rend(); it++)
{
if (exclude_mining_txs)
{
if(it->is_mining)
continue;
}
trs.push_back(*it);
last_item_index = it - m_transfer_history.rbegin();
if (trs.size() >= count)
{
break;
}
}
total = m_transfer_history.size();
}
//----------------------------------------------------------------------------------------------------
@ -3281,10 +3291,16 @@ bool wallet2::build_minted_block(const currency::COMMAND_RPC_SCAN_POS::request&
return true;
}
//----------------------------------------------------------------------------------------------------
void wallet2::get_unconfirmed_transfers(std::vector<wallet_public::wallet_transfer_info>& trs)
void wallet2::get_unconfirmed_transfers(std::vector<wallet_public::wallet_transfer_info>& trs, bool exclude_mining_txs)
{
for (auto& u : m_unconfirmed_txs)
{
if (exclude_mining_txs && u.second.is_mining)
{
continue;
}
trs.push_back(u.second);
}
}
//----------------------------------------------------------------------------------------------------
void wallet2::set_core_runtime_config(const currency::core_runtime_config& pc)

View file

@ -482,10 +482,10 @@ namespace tools
currency::account_base& get_account() { return m_account; }
const currency::account_base& get_account() const { return m_account; }
void get_recent_transfers_history(std::vector<wallet_public::wallet_transfer_info>& trs, size_t offset, size_t count, uint64_t& total);
void get_recent_transfers_history(std::vector<wallet_public::wallet_transfer_info>& trs, size_t offset, size_t count, uint64_t& total, uint64_t& last_item_index, bool exclude_mining_txs = false);
uint64_t get_recent_transfers_total_count();
uint64_t get_transfer_entries_count();
void get_unconfirmed_transfers(std::vector<wallet_public::wallet_transfer_info>& trs);
void get_unconfirmed_transfers(std::vector<wallet_public::wallet_transfer_info>& trs, bool exclude_mining_txs = false);
void init(const std::string& daemon_address = "http://localhost:8080");
bool deinit();

View file

@ -275,11 +275,13 @@ namespace wallet_public
of GET_RECENT_TXS_AND_INFO with offsets)
*/
bool update_provision_info;
bool exclude_mining_txs;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(offset)
KV_SERIALIZE(count)
KV_SERIALIZE(update_provision_info)
KV_SERIALIZE(exclude_mining_txs)
END_KV_SERIALIZE_MAP()
};
@ -288,11 +290,13 @@ namespace wallet_public
wallet_provision_info pi;
std::vector<wallet_transfer_info> transfers;
uint64_t total_transfers;
uint64_t last_item_index;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(pi)
KV_SERIALIZE(transfers)
KV_SERIALIZE(total_transfers)
KV_SERIALIZE(last_item_index)
END_KV_SERIALIZE_MAP()
};
};

View file

@ -223,9 +223,9 @@ namespace tools
}
if (req.offset == 0)
m_wallet.get_unconfirmed_transfers(res.transfers);
m_wallet.get_unconfirmed_transfers(res.transfers, req.exclude_mining_txs);
m_wallet.get_recent_transfers_history(res.transfers, req.offset, req.count, res.total_transfers);
m_wallet.get_recent_transfers_history(res.transfers, req.offset, req.count, res.total_transfers, res.last_item_index, req.exclude_mining_txs);
return true;
}

View file

@ -815,7 +815,7 @@ std::string wallets_manager::get_my_offers(const bc_services::core_offers_filter
#endif
}
std::string wallets_manager::open_wallet(const std::wstring& path, const std::string& password, uint64_t txs_to_return, view::open_wallet_response& owr)
std::string wallets_manager::open_wallet(const std::wstring& path, const std::string& password, uint64_t txs_to_return, view::open_wallet_response& owr, bool exclude_mining_txs)
{
// check if that file already opened
SHARED_CRITICAL_REGION_BEGIN(m_wallets_lock);
@ -854,9 +854,9 @@ std::string wallets_manager::open_wallet(const std::wstring& path, const std::st
if (w->is_watch_only() && !w->is_auditable())
return API_RETURN_CODE_WALLET_WATCH_ONLY_NOT_SUPPORTED;
w->get_recent_transfers_history(owr.recent_history.history, 0, txs_to_return, owr.recent_history.total_history_items);
w->get_recent_transfers_history(owr.recent_history.history, 0, txs_to_return, owr.recent_history.total_history_items, owr.recent_history.last_item_index, exclude_mining_txs);
//w->get_unconfirmed_transfers(owr.recent_history.unconfirmed);
w->get_unconfirmed_transfers(owr.recent_history.history);
w->get_unconfirmed_transfers(owr.recent_history.history, exclude_mining_txs);
owr.wallet_local_bc_size = w->get_blockchain_current_size();
//workaround for missed fee
owr.seed = w->get_account().get_seed_phrase();
@ -912,7 +912,7 @@ bool wallets_manager::get_opened_wallets(std::list<view::open_wallet_response>&
return true;
}
std::string wallets_manager::get_recent_transfers(size_t wallet_id, uint64_t offset, uint64_t count, view::transfers_array& tr_hist)
std::string wallets_manager::get_recent_transfers(size_t wallet_id, uint64_t offset, uint64_t count, view::transfers_array& tr_hist, bool exclude_mining_txs)
{
GET_WALLET_BY_ID(wallet_id, w);
auto wallet_locked = w.try_lock();
@ -921,8 +921,8 @@ std::string wallets_manager::get_recent_transfers(size_t wallet_id, uint64_t off
return API_RETURN_CODE_CORE_BUSY;
}
w->get()->get_unconfirmed_transfers(tr_hist.unconfirmed);
w->get()->get_recent_transfers_history(tr_hist.history, offset, count, tr_hist.total_history_items);
w->get()->get_unconfirmed_transfers(tr_hist.unconfirmed, exclude_mining_txs);
w->get()->get_recent_transfers_history(tr_hist.history, offset, count, tr_hist.total_history_items, tr_hist.last_item_index, exclude_mining_txs);
auto fix_tx = [](tools::wallet_public::wallet_transfer_info& wti) -> void {
wti.show_sender = currency::is_showing_sender_addres(wti.tx);

View file

@ -97,13 +97,13 @@ public:
bool quick_clear_wallets_no_save();
bool send_stop_signal();
bool get_opened_wallets(std::list<view::open_wallet_response>& result);
std::string open_wallet(const std::wstring& path, const std::string& password, uint64_t txs_to_return, view::open_wallet_response& owr);
std::string open_wallet(const std::wstring& path, const std::string& password, uint64_t txs_to_return, view::open_wallet_response& owr, bool exclude_mining_txs = false);
std::string generate_wallet(const std::wstring& path, const std::string& password, view::open_wallet_response& owr);
std::string restore_wallet(const std::wstring& path, const std::string& password, const std::string& restore_key, view::open_wallet_response& owr);
std::string invoke(uint64_t wallet_id, std::string params);
std::string get_wallet_status(uint64_t wallet_id);
std::string run_wallet(uint64_t wallet_id);
std::string get_recent_transfers(size_t wallet_id, uint64_t offset, uint64_t count, view::transfers_array& tr_hist);
std::string get_recent_transfers(size_t wallet_id, uint64_t offset, uint64_t count, view::transfers_array& tr_hist, bool exclude_mining_txs = false);
std::string get_wallet_info(size_t wallet_id, view::wallet_info& wi);
std::string get_contracts(size_t wallet_id, std::vector<tools::wallet_public::escrow_contract_details>& contracts);
std::string create_proposal(const view::create_proposal_param_gui& cpp);