mirror of
https://github.com/Expand-sys/CCash
synced 2025-12-17 00:22:14 +11:00
🐛 saving of logs bug fixed
This commit is contained in:
parent
59417ccebf
commit
0d7b7b5df2
4 changed files with 29 additions and 24 deletions
|
|
@ -4,13 +4,6 @@
|
|||
"address": "0.0.0.0",
|
||||
"port": 80,
|
||||
"https": false
|
||||
},
|
||||
{
|
||||
"address": "0.0.0.0",
|
||||
"port": 443,
|
||||
"https": true,
|
||||
"cert": "",
|
||||
"key": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -175,15 +175,15 @@ public:
|
|||
if constexpr (max_log_size)
|
||||
{
|
||||
if (!users.if_contains(name, [&res, &attempt](const User &u) {
|
||||
if (u.password != XXH3_64bits(attempt.data(), attempt.size()))
|
||||
{
|
||||
res = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = u.log.Serialize();
|
||||
}
|
||||
}))
|
||||
if (u.password != XXH3_64bits(attempt.data(), attempt.size()))
|
||||
{
|
||||
res = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = u.log.Serialize();
|
||||
}
|
||||
}))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -233,7 +233,7 @@ public:
|
|||
user_save.close();
|
||||
for (const auto &u : temp.getMemberNames())
|
||||
{
|
||||
if constexpr(max_log_size)
|
||||
if constexpr (max_log_size)
|
||||
{
|
||||
users.try_emplace(u, temp[u]["balance"].asUInt(), std::move(temp[u]["password"].asUInt64()), std::move(temp[u]["log"]));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ struct Log
|
|||
{
|
||||
if (data.size() == end)
|
||||
{
|
||||
data.resize(data.size()+pre_log_size); //prefetching memory
|
||||
data.resize(data.size() + pre_log_size); //prefetching memory
|
||||
}
|
||||
for (uint32_t i = end; i > 0; --i)
|
||||
{
|
||||
|
|
@ -27,7 +27,7 @@ struct Log
|
|||
Json::Value Serialize() const
|
||||
{
|
||||
Json::Value res;
|
||||
for (uint32_t i = 0; i < data.size() && data[i].amount; ++i)
|
||||
for (uint32_t i = 0; i < end; ++i)
|
||||
{
|
||||
res[i]["to"] = data[i].to;
|
||||
res[i]["from"] = data[i].from;
|
||||
|
|
|
|||
|
|
@ -31,14 +31,26 @@ struct User
|
|||
* @param init_pass
|
||||
*/
|
||||
User(uint32_t init_bal, uint64_t init_pass) : balance(init_bal), password(init_pass) {}
|
||||
User(uint32_t init_bal, uint64_t init_pass, Json::Value&& log_j) : balance(init_bal), password(init_pass)
|
||||
User(uint32_t init_bal, uint64_t init_pass, Json::Value &&log_j) : balance(init_bal), password(init_pass)
|
||||
{
|
||||
if(log_j.size())
|
||||
std::cout << log_j << '\n';
|
||||
if (log_j.size())
|
||||
{
|
||||
log.data.resize(log_j.size()+pre_log_size);
|
||||
log.end = log_j.size();
|
||||
for(uint32_t i = 0; i < log_j.size() && i < max_log_size; ++i)
|
||||
if (max_log_size > log_j.size() + pre_log_size)
|
||||
{
|
||||
std::cout << "setting size to " << log_j.size() + pre_log_size << '\n';
|
||||
log.data.resize(log_j.size() + pre_log_size);
|
||||
log.end = log_j.size();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "setting size to " << max_log_size << '\n';
|
||||
log.data.resize(max_log_size);
|
||||
log.end = max_log_size;
|
||||
}
|
||||
for (uint32_t i = 0; i < log_j.size() && i < max_log_size; ++i)
|
||||
{
|
||||
std::cout << i << '\n';
|
||||
log.data[i] = std::move(Transaction(log_j[i]["from"].asCString(), log_j[i]["to"].asCString(), log_j[i]["balance"].asUInt()));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue