You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
neroshop/src/core/protocol/p2p/key_mapper.hpp

38 lines
2.0 KiB

#pragma once
#include <iostream>
#include <string>
#include <unordered_map>
#include <vector>
#include <utility> // for std::pair
namespace neroshop {
struct KeyMapper { // maps search terms to DHT keys
KeyMapper() = default;
~KeyMapper();
std::unordered_map<std::string, std::vector<std::string>> product_ids;
std::unordered_map<std::string, std::vector<std::string>> product_names; // maps a product name to a list of corresponding listing keys
std::unordered_map<std::string, std::vector<std::string>> product_categories;
std::unordered_map<std::string, std::vector<std::string>> product_tags;
std::unordered_map<std::string, std::vector<std::string>> product_codes;
std::unordered_map<std::string, std::vector<std::string>> listing_ids;
std::unordered_map<std::string, std::vector<std::string>> listing_locations;
std::unordered_map<std::string, std::vector<std::string>> seller_ids;
std::unordered_map<std::string, std::vector<std::string>> user_ids; // maps a monero address (ID) to the corresponding account key
std::unordered_map<std::string, std::vector<std::string>> display_names; // maps a display name to a list of corresponding account keys
std::unordered_map<std::string, std::vector<std::string>> order_ids; // maps a order uuid to the corresponding order key.
std::unordered_map<std::string, std::vector<std::string>> product_ratings;
std::unordered_map<std::string, std::vector<std::string>> seller_ratings;
std::unordered_map<std::string, std::vector<std::string>> messages;
void add(const std::string& key, const std::string& value); // must be JSON value
void sync(); // syncs mapping data to local database
std::pair<std::string, std::string> serialize(); // Converts mapping data to JSON format
std::vector<std::string> search_product_by_name(const std::string& product_name);//std::vector<std::string> search_user_by_id(const std::string& );//std::vector<std::string> search_order_by_id(const std::string& );
};
}