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())); }