diff --git a/include/bank.hpp b/include/bank.hpp index eeb0066..d4256b2 100644 --- a/include/bank.hpp +++ b/include/bank.hpp @@ -207,15 +207,18 @@ public: Json::Value res; if (!(logs.if_contains(name, [&res](const Log &l) { + uint32_t j; for (uint32_t i = l.data.size() - 1; i > 0; --i) { + j = 99 - i; if (!l.data[i].amount) { return; } - res[99 - i]["to"] = l.data[i].to; - res[99 - i]["from"] = l.data[i].from; - res[99 - i]["amount"] = l.data[i].amount; + res[j]["to"] = l.data[i].to; + res[j]["from"] = l.data[i].from; + res[j]["amount"] = l.data[i].amount; + res[j]["time"] = l.data[i].time; } }))) { diff --git a/include/transactions.hpp b/include/transactions.hpp index 0107a30..9c92ff4 100644 --- a/include/transactions.hpp +++ b/include/transactions.hpp @@ -1,11 +1,14 @@ #pragma once +#include #include //24 bytes total struct Transaction { + std::string from = "", to = ""; uint32_t amount = 0; + uint32_t time = 0; void Concatinate(std::string &s) { @@ -21,9 +24,11 @@ struct Transaction Transaction() = default; Transaction(std::string from_str, std::string to_str, uint32_t amount) : amount(amount) { + using namespace std::chrono; Concatinate(from_str); Concatinate(to_str); from = std::move(from_str); to = std::move(to_str); + time = duration_cast(system_clock::now().time_since_epoch()).count(); } }; \ No newline at end of file