1
0
Fork 0
forked from lthn/blockchain

added asset_id for UI_to_wallet api, added preloading whitelist for wallet before balance request

This commit is contained in:
cryptozoidberg 2022-11-28 22:10:50 +01:00
parent 0d84a92096
commit 1c52911757
No known key found for this signature in database
GPG key ID: 22DEB97A54C6FDEC
3 changed files with 8 additions and 5 deletions

View file

@ -35,10 +35,12 @@ namespace view
{
std::string address;
std::string amount;
crypto::hash asset_id;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(address)
KV_SERIALIZE(amount)
KV_SERIALIZE_POD_AS_HEX_STRING(asset_id)
END_KV_SERIALIZE_MAP()
};

View file

@ -3144,6 +3144,7 @@ bool wallet2::balance(std::unordered_map<crypto::hash, wallet_public::asset_bala
//----------------------------------------------------------------------------------------------------
bool wallet2::balance(std::list<wallet_public::asset_balance_entry>& balances, uint64_t& mined) const
{
load_whitelisted_tokens_if_not_loaded();
std::unordered_map<crypto::hash, wallet_public::asset_balance_entry_base> balances_map;
this->balance(balances_map, mined);
for (const auto& item : balances_map)
@ -3221,7 +3222,7 @@ bool wallet2::delete_custom_asset_id(const crypto::hash& asset_id)
return true;
}
//----------------------------------------------------------------------------------------------------
bool wallet2::load_whitelisted_tokens()
bool wallet2::load_whitelisted_tokens() const
{
m_whitelisted_assets.clear();
std::string body;
@ -3236,7 +3237,7 @@ bool wallet2::load_whitelisted_tokens()
return true;
}
//----------------------------------------------------------------------------------------------------
bool wallet2::load_whitelisted_tokens_if_not_loaded()
bool wallet2::load_whitelisted_tokens_if_not_loaded() const
{
if (m_whitelisted_assets.size())
{

View file

@ -901,8 +901,8 @@ namespace tools
bool add_custom_asset_id(const crypto::hash& asset_id);
bool delete_custom_asset_id(const crypto::hash& asset_id);
bool load_whitelisted_tokens_if_not_loaded();
bool load_whitelisted_tokens();
bool load_whitelisted_tokens_if_not_loaded() const;
bool load_whitelisted_tokens()const;
/*
create_htlc_proposal: if htlc_hash == null_hash, then this wallet is originator of the atomic process, and
@ -1101,7 +1101,7 @@ private:
std::unordered_map<crypto::hash, crypto::secret_key> m_tx_keys;
std::unordered_map<crypto::hash, wallet_own_asset_context> m_own_asset_descriptors;
std::unordered_map<crypto::hash, currency::asset_descriptor_base> m_custom_assets; //assets that manually added by user
std::unordered_map<crypto::hash, currency::asset_descriptor_base> m_whitelisted_assets; //assets that manually added by user
mutable std::unordered_map<crypto::hash, currency::asset_descriptor_base> m_whitelisted_assets; //assets that whitelisted
std::multimap<uint64_t, htlc_expiration_trigger> m_htlcs; //map [expired_if_more_then] -> height of expiration