From b0af12d4ce16f4dfc607d52aeee6f32fe7ef928b Mon Sep 17 00:00:00 2001 From: EntireTwix Date: Wed, 21 Apr 2021 19:17:00 -0700 Subject: [PATCH] AdminDel/Del now delete logs aswell --- include/bank.hpp | 22 ++++++++++++++++++---- include/transactions.hpp | 1 + 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/include/bank.hpp b/include/bank.hpp index 3c4e4f9..04a44f5 100644 --- a/include/bank.hpp +++ b/include/bank.hpp @@ -61,13 +61,27 @@ public: bool DelUser(const std::string &name, const std::string &attempt) { - std::shared_lock lock{size_l}; - return users.erase_if(name, [&attempt](const User &u) { return (XXH3_64bits(attempt.data(), attempt.size()) == u.password); }); + { + std::shared_lock lock{size_l}; + bool state = users.erase_if(name, [&attempt](User &u) { return (XXH3_64bits(attempt.data(), attempt.size()) == u.password); }); + } + if (state) + { + logs.erase_if(name, [](User &u) {}) + } + return state; } bool AdminDelUser(const std::string &name, const std::string &attempt) { - std::shared_lock lock{size_l}; - return users.erase_if(name, [this, &attempt](const User &) { return (admin_pass == attempt); }); + { + std::shared_lock lock{size_l}; + bool state = users.erase_if(name, [this, &attempt](const User &) { return (admin_pass == attempt); }); + } + if (state) + { + logs.erase_if(name, [](User &u) {}); + } + return state; } bool SendFunds(const std::string &a_name, const std::string &b_name, uint_fast32_t amount, const std::string &attempt) diff --git a/include/transactions.hpp b/include/transactions.hpp index 29f98f2..0107a30 100644 --- a/include/transactions.hpp +++ b/include/transactions.hpp @@ -1,6 +1,7 @@ #pragma once #include +//24 bytes total struct Transaction { std::string from = "", to = "";