From aa7a389de0a4b3126324221949cdc684e4790db9 Mon Sep 17 00:00:00 2001 From: EntireTwix Date: Thu, 3 Jun 2021 01:17:30 -0700 Subject: [PATCH] :bug: degrading logs bug --- include/log.hpp | 13 ++++++++----- include/user.hpp | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/include/log.hpp b/include/log.hpp index 5341036..f639f40 100644 --- a/include/log.hpp +++ b/include/log.hpp @@ -31,12 +31,15 @@ struct Log Json::Value Serialize() const { Json::Value res; - for (uint32_t i = 0; i < end; ++i) + if(data.size()) { - res[i]["to"] = data[i].to; - res[i]["from"] = data[i].from; - res[i]["amount"] = (Json::UInt)data[i].amount; - res[i]["time"] = (Json::UInt64)data[i].time; + for (uint32_t i = 0; i < end + 1; ++i) + { + res[i]["to"] = data[i].to; + res[i]["from"] = data[i].from; + res[i]["amount"] = (Json::UInt)data[i].amount; + res[i]["time"] = (Json::UInt64)data[i].time; + } } return res; } diff --git a/include/user.hpp b/include/user.hpp index cbb7005..ca52299 100644 --- a/include/user.hpp +++ b/include/user.hpp @@ -45,7 +45,7 @@ struct User log.data.resize(max_log_size); log.end = max_log_size - 1; } - for (uint32_t i = 0; i < log.end; ++i) + for (uint32_t i = 0; i < log.end + 1; ++i) { 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())); }