Saves to LNS cache and retrieves

This commit is contained in:
Sean Darcy 2020-05-07 05:37:35 +00:00 committed by Jason Rhinelander
parent f77fca124d
commit b734843d77
3 changed files with 21 additions and 33 deletions

View File

@ -6529,13 +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);
//TODO:(sean)
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)
@ -7005,12 +7006,12 @@ 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;
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 << ' ';
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}));

View File

@ -12993,27 +12993,15 @@ uint64_t wallet2::get_approximate_blockchain_height() const
}
//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 )
void wallet2::set_lns_cache_record(const wallet2::lns_detail& detail)
{
//lns_records_cache.push_back(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;
//}
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)
{

View File

@ -808,10 +808,9 @@ private:
};
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);
void set_lns_cache_record(const wallet2::lns_detail& detail);
//std::vector<lns_detail> get_lns_cache_record(std::string name, std::string value, std::string owner, std::string backup_owner);
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();