functions to save to cache

This commit is contained in:
Sean Darcy 2020-05-07 02:17:55 +00:00 committed by Jason Rhinelander
parent f679a7f275
commit f77fca124d
4 changed files with 54 additions and 1 deletions

View File

@ -6529,6 +6529,14 @@ bool simple_wallet::lns_buy_mapping(std::vector<std::string> args)
info.is_subaddress = m_current_subaddress_account != 0;
dsts.push_back(info);
//tools::wallet2::lns_detail detail = {
//lns::mapping_type::session,
//"testname",
//"testvalue",
//"testowner",
//"testbackupowner" };
//m_wallet->set_lns_cache_record(detail);
std::cout << std::endl << tr("Buying Loki Name System Record") << std::endl << std::endl;
if (type == lns::mapping_type::session)
std::cout << boost::format(tr("Session Name: %s")) % name << std::endl;
@ -6555,6 +6563,16 @@ bool simple_wallet::lns_buy_mapping(std::vector<std::string> args)
if (!confirm_and_send_tx(dsts, ptx_vector, priority == tools::tx_priority_blink))
return false;
//TODO(sean)
std::cout << tr("Setting the LNS Cache") << std::endl;
//m_wallet->set_lns_cache_record(
//lns::mapping_type::session,
//name,
//value,
//owner.size() ? owner : m_wallet->get_subaddress_as_str({m_current_subaddress_account, 0}),
//backup_owner.size() ? backup_owner : "");
//
}
catch (const std::exception &e)
{
@ -6986,6 +7004,13 @@ bool simple_wallet::lns_print_owners_to_names(const std::vector<std::string>& ar
{
for (uint32_t index = 0; index < m_wallet->get_num_subaddresses(m_current_subaddress_account); ++index)
{
//TODO(sean)
//std::cout << tr("Retrieving the Cache") << std::endl;
//std::vector<tools::wallet2::lns_detail> cache = m_wallet->get_lns_cache_record("", "", m_wallet->get_subaddress_as_str({m_current_subaddress_account, index}) , "");
//std::cout << cache.size() << std::endl;
//for(unsigned int i=0; i<cache.size(); ++i)
//std::cout << cache[i].name << ' ';
if (requests.back().entries.size() >= cryptonote::rpc::LNS_OWNERS_TO_NAMES::MAX_REQUEST_ENTRIES)
requests.emplace_back();
requests.back().entries.push_back(m_wallet->get_subaddress_as_str({m_current_subaddress_account, index}));

0
src/wallet/wallet Normal file
View File

View File

@ -12992,6 +12992,29 @@ uint64_t wallet2::get_approximate_blockchain_height() const
return approx_blockchain_height;
}
//TODO(sean)
//void wallet2::set_lns_cache_record(lns::mapping_type type, std::string name, std::string value, std::string owner, std::string backup_owner)
//{
//lns_detail detail = {
//type,
//name,
//value,
//owner,
//backup_owner,
//};
//lns_records_cache.push_back(detail);
//}
void wallet2::set_lns_cache_record(wallet2::lns_detail detail )
{
//lns_records_cache.push_back(detail);
}
//std::vector<wallet2::lns_detail> wallet2::get_lns_cache_record(std::string name, std::string value, std::string owner, std::string backup_owner)
//{
//return lns_records_cache;
//}
void wallet2::set_tx_note(const crypto::hash &txid, const std::string &note)
{
m_tx_notes[txid] = note;

View File

@ -806,6 +806,12 @@ private:
std::string owner;
std::string backup_owner;
};
std::vector<lns_detail> lns_records_cache;
//void set_lns_cache_record(lns::mapping_type type, std::string name, std::string value, std::string owner, std::string backup_owner);
void set_lns_cache_record(lns_detail detail);
//std::vector<lns_detail> get_lns_cache_record(std::string name, std::string value, std::string owner, std::string backup_owner);
uint64_t get_blockchain_current_height() const { return m_light_wallet_blockchain_height ? m_light_wallet_blockchain_height : m_blockchain.size(); }
void rescan_spent();
@ -1547,7 +1553,6 @@ private:
std::unordered_map<crypto::public_key, cryptonote::subaddress_index> m_subaddresses;
std::vector<std::vector<std::string>> m_subaddress_labels;
std::unordered_map<crypto::hash, std::string> m_tx_notes;
std::vector<lns_detail> lns_records_cache;
std::unordered_map<std::string, std::string> m_attributes;
std::vector<tools::wallet2::address_book_row> m_address_book;
std::pair<std::map<std::string, std::string>, std::vector<std::string>> m_account_tags;