From dc11416d9aecc33be5efad143e1c48994b53ad48 Mon Sep 17 00:00:00 2001 From: William Katz Date: Fri, 28 May 2021 02:39:57 -0700 Subject: [PATCH 1/3] New time constructor --- include/transactions.hpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/transactions.hpp b/include/transactions.hpp index fe519f9..0238b63 100644 --- a/include/transactions.hpp +++ b/include/transactions.hpp @@ -11,6 +11,11 @@ struct Transaction uint64_t time = 0; Transaction() = default; + Transaction(std::string from_str, std::string to_str, uint32_t amount uint64_t time) : amount(amount), time(time) + { + from = std::move(from_str); + to = std::move(to_str); + } Transaction(std::string from_str, std::string to_str, uint32_t amount) : amount(amount) { using namespace std::chrono; @@ -18,4 +23,4 @@ struct Transaction to = std::move(to_str); time = duration_cast(system_clock::now().time_since_epoch()).count(); } -}; \ No newline at end of file +}; From 662685a0ac289134c23cfa69a7b2e128a7501068 Mon Sep 17 00:00:00 2001 From: William Katz Date: Fri, 28 May 2021 02:41:13 -0700 Subject: [PATCH 2/3] Update user.hpp --- include/user.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/user.hpp b/include/user.hpp index 04526f6..8d2d88f 100644 --- a/include/user.hpp +++ b/include/user.hpp @@ -47,7 +47,7 @@ struct User } for (uint32_t i = 0; i < log.end; ++i) { - log.data[i] = std::move(Transaction(log_j[i]["from"].asCString(), log_j[i]["to"].asCString(), log_j[i]["amount"].asUInt())); + log.data[i] = std::move(Transaction(log_j[i]["from"].asCString(), log_j[i]["to"].asCString(), log_j[i]["amount"].asUInt(), log_j[i]["time"].asUInt64())); } } } From 48a7c34f6f9ccd66ae815aba58633bc242dd4a46 Mon Sep 17 00:00:00 2001 From: William Katz Date: Fri, 28 May 2021 02:47:17 -0700 Subject: [PATCH 3/3] typo --- include/transactions.hpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/include/transactions.hpp b/include/transactions.hpp index 0238b63..996c3de 100644 --- a/include/transactions.hpp +++ b/include/transactions.hpp @@ -2,16 +2,14 @@ #include #include -//42 bytes total struct Transaction { - std::string from = "", to = ""; uint32_t amount = 0; uint64_t time = 0; Transaction() = default; - Transaction(std::string from_str, std::string to_str, uint32_t amount uint64_t time) : amount(amount), time(time) + Transaction(std::string from_str, std::string to_str, uint32_t amount, uint64_t time) : amount(amount), time(time) { from = std::move(from_str); to = std::move(to_str);