mirror of
https://github.com/monero-project/monero.git
synced 2025-08-23 09:35:10 -04:00
serialization: remove container wrappers and serialize directly
Some downstream code (most notably PR https://github.com/UkoeHB/monero/pull/25) wants to use the src/serialization lib for storing information persistently. When one builds classes/machines wishing to serialize containers, they must use the `serializable_*` container classes. In this case, this makes the Seraphis library code unnecessarily tightly coupled with the src/serialization code since one cannot swap out their type of storage format without major refactoring of class field types. By serializing STL containers directly, we can abstract the serialization details away, making for much cleaner design. Also small bonus side effect of this change is that STL containers with custom Comparators, Allocators, and Hashers are serializable. `std::multimap` is added to the list of serializable containers. Depends upon https://github.com/monero-project/monero/pull/9069.
This commit is contained in:
parent
a11e03afa6
commit
2525200185
5 changed files with 81 additions and 125 deletions
|
@ -1821,7 +1821,7 @@ void reattach_blockchain(hashchain &blockchain, wallet2::detached_blockchain_dat
|
|||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
bool has_nonrequested_tx_at_height_or_above_requested(uint64_t height, const std::unordered_set<crypto::hash> &requested_txids, const wallet2::transfer_container &transfers,
|
||||
const wallet2::payment_container &payments, const serializable_unordered_map<crypto::hash, wallet2::confirmed_transfer_details> &confirmed_txs)
|
||||
const wallet2::payment_container &payments, const std::unordered_map<crypto::hash, wallet2::confirmed_transfer_details> &confirmed_txs)
|
||||
{
|
||||
for (const auto &td : transfers)
|
||||
if (td.m_block_height >= height && requested_txids.find(td.m_txid) == requested_txids.end())
|
||||
|
@ -11985,7 +11985,7 @@ std::string wallet2::get_reserve_proof(const boost::optional<std::pair<uint32_t,
|
|||
}
|
||||
|
||||
// collect all subaddress spend keys that received those outputs and generate their signatures
|
||||
serializable_unordered_map<crypto::public_key, crypto::signature> subaddr_spendkeys;
|
||||
std::unordered_map<crypto::public_key, crypto::signature> subaddr_spendkeys;
|
||||
for (const cryptonote::subaddress_index &index : subaddr_indices)
|
||||
{
|
||||
crypto::secret_key subaddr_spend_skey = m_account.get_keys().m_spend_secret_key;
|
||||
|
@ -12030,7 +12030,7 @@ bool wallet2::check_reserve_proof(const cryptonote::account_public_address &addr
|
|||
|
||||
bool loaded = false;
|
||||
std::vector<reserve_proof_entry> proofs;
|
||||
serializable_unordered_map<crypto::public_key, crypto::signature> subaddr_spendkeys;
|
||||
std::unordered_map<crypto::public_key, crypto::signature> subaddr_spendkeys;
|
||||
try
|
||||
{
|
||||
binary_archive<false> ar{epee::strspan<std::uint8_t>(sig_decoded)};
|
||||
|
@ -12044,7 +12044,7 @@ bool wallet2::check_reserve_proof(const cryptonote::account_public_address &addr
|
|||
{
|
||||
std::istringstream iss(sig_decoded);
|
||||
boost::archive::portable_binary_iarchive ar(iss);
|
||||
ar >> proofs >> subaddr_spendkeys.parent();
|
||||
ar >> proofs >> subaddr_spendkeys;
|
||||
}
|
||||
|
||||
THROW_WALLET_EXCEPTION_IF(subaddr_spendkeys.count(address.m_spend_public_key) == 0, error::wallet_internal_error,
|
||||
|
@ -12288,7 +12288,7 @@ std::string wallet2::get_description() const
|
|||
return "";
|
||||
}
|
||||
|
||||
const std::pair<serializable_map<std::string, std::string>, std::vector<std::string>>& wallet2::get_account_tags()
|
||||
const std::pair<std::map<std::string, std::string>, std::vector<std::string>>& wallet2::get_account_tags()
|
||||
{
|
||||
// ensure consistency
|
||||
if (m_account_tags.second.size() != get_num_subaddress_accounts())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue