diff --git a/include/bank.hpp b/include/bank.hpp index 95584ae..3c4e4f9 100644 --- a/include/bank.hpp +++ b/include/bank.hpp @@ -109,21 +109,22 @@ public: if (state) { //if user lacks a log, one is created, this is to reduce usage - Transaction temp(a_name, b_name, amount, false); + Transaction temp(a_name, b_name, amount); + Transaction temp2(a_name, b_name, amount); + if (!logs.contains(a_name)) { logs.try_emplace(a_name); } logs.modify_if(a_name, [&temp](Log &l) { - l.AddTrans(temp); + l.AddTrans(std::move(temp)); }); if (!logs.contains(b_name)) { logs.try_emplace(b_name); } - temp.recieving = true; - logs.modify_if(b_name, [&temp](Log &l) { - l.AddTrans(temp); + logs.modify_if(b_name, [&temp2](Log &l) { + l.AddTrans(std::move(temp2)); }); } diff --git a/include/log.hpp b/include/log.hpp index f76f4d3..9c83e53 100644 --- a/include/log.hpp +++ b/include/log.hpp @@ -6,7 +6,7 @@ struct Log { std::array data; - void AddTrans(const Transaction &v) + void AddTrans(Transaction &&v) { std::rotate(data.begin(), data.begin() + 1, data.end()); data[99] = std::move(v);