🐛 degrading logs bug

This commit is contained in:
EntireTwix 2021-06-03 01:17:30 -07:00
parent 9490219747
commit aa7a389de0
2 changed files with 9 additions and 6 deletions

View file

@ -31,13 +31,16 @@ struct Log
Json::Value Serialize() const Json::Value Serialize() const
{ {
Json::Value res; Json::Value res;
for (uint32_t i = 0; i < end; ++i) if(data.size())
{
for (uint32_t i = 0; i < end + 1; ++i)
{ {
res[i]["to"] = data[i].to; res[i]["to"] = data[i].to;
res[i]["from"] = data[i].from; res[i]["from"] = data[i].from;
res[i]["amount"] = (Json::UInt)data[i].amount; res[i]["amount"] = (Json::UInt)data[i].amount;
res[i]["time"] = (Json::UInt64)data[i].time; res[i]["time"] = (Json::UInt64)data[i].time;
} }
}
return res; return res;
} }
}; };

View file

@ -45,7 +45,7 @@ struct User
log.data.resize(max_log_size); log.data.resize(max_log_size);
log.end = max_log_size - 1; 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())); 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()));
} }