time added as part of log

This commit is contained in:
EntireTwix 2021-04-21 20:54:49 -07:00
parent fcff1c5074
commit d96364d1f0
2 changed files with 11 additions and 3 deletions

View file

@ -207,15 +207,18 @@ public:
Json::Value res; Json::Value res;
if (!(logs.if_contains(name, [&res](const Log &l) { if (!(logs.if_contains(name, [&res](const Log &l) {
uint32_t j;
for (uint32_t i = l.data.size() - 1; i > 0; --i) for (uint32_t i = l.data.size() - 1; i > 0; --i)
{ {
j = 99 - i;
if (!l.data[i].amount) if (!l.data[i].amount)
{ {
return; return;
} }
res[99 - i]["to"] = l.data[i].to; res[j]["to"] = l.data[i].to;
res[99 - i]["from"] = l.data[i].from; res[j]["from"] = l.data[i].from;
res[99 - i]["amount"] = l.data[i].amount; res[j]["amount"] = l.data[i].amount;
res[j]["time"] = l.data[i].time;
} }
}))) })))
{ {

View file

@ -1,11 +1,14 @@
#pragma once #pragma once
#include <chrono>
#include <cstdint> #include <cstdint>
//24 bytes total //24 bytes total
struct Transaction struct Transaction
{ {
std::string from = "", to = ""; std::string from = "", to = "";
uint32_t amount = 0; uint32_t amount = 0;
uint32_t time = 0;
void Concatinate(std::string &s) void Concatinate(std::string &s)
{ {
@ -21,9 +24,11 @@ struct Transaction
Transaction() = default; Transaction() = default;
Transaction(std::string from_str, std::string to_str, uint32_t amount) : amount(amount) Transaction(std::string from_str, std::string to_str, uint32_t amount) : amount(amount)
{ {
using namespace std::chrono;
Concatinate(from_str); Concatinate(from_str);
Concatinate(to_str); Concatinate(to_str);
from = std::move(from_str); from = std::move(from_str);
to = std::move(to_str); to = std::move(to_str);
time = duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count();
} }
}; };