🐛 fixed logging broken

This commit is contained in:
EntireTwix 2021-05-03 17:31:21 -07:00
parent 4689fe7077
commit 8f3f2f0b32
2 changed files with 12 additions and 9 deletions

View file

@ -107,6 +107,7 @@ public:
{
Transaction temp(a_name, b_name, amount);
Transaction temp2 = temp;
std::cout << temp.from << ' ' << temp.to << '\n';
users.modify_if(a_name, [&temp](User &a) {
a.log.AddTrans(std::move(temp));
});
@ -176,12 +177,8 @@ public:
return;
}
for (uint32_t i = 0; i < u.log.data.size(); ++i)
for (uint32_t i = 0; i < u.log.data.size() && u.log.data[i].amount; ++i)
{
if (!u.log.data[i].amount)
{
break;
}
res[i]["to"] = u.log.data[i].to;
res[i]["from"] = u.log.data[i].from;
res[i]["amount"] = u.log.data[i].amount;

View file

@ -6,21 +6,27 @@
struct Log
{
std::vector<Transaction> data;
uint32_t end = 0;
void AddTrans(Transaction &&v)
{
if (!data.size())
{
data.resize(50);
}
for (size_t i = 1; i < data.size(); ++i)
if (end)
{
if (!data[i].amount)
for (uint32_t i = end; i > 0; --i)
{
std::cout << i << '\n';
data[i] = std::move(data[i - 1]);
break;
}
data[i] = std::move(data[i - 1]);
}
data[0] = std::move(v);
if (end < 50)
{
++end;
}
}
};
//[*][*][]