mirror of
https://github.com/Expand-sys/CCash
synced 2025-12-17 00:22:14 +11:00
🐛 Max log 1 optimizations fixed
This commit is contained in:
parent
ae219af90e
commit
99f35a11df
2 changed files with 15 additions and 8 deletions
|
|
@ -25,7 +25,7 @@ size_t Bank::NumOfUsers() const noexcept { return users.size(); }
|
|||
uint64_t Bank::NumOfLogs() const noexcept
|
||||
{
|
||||
uint64_t res = 0;
|
||||
#if MAX_LOG_SIZE > 0
|
||||
#if MAX_LOG_SIZE > 1
|
||||
for (const auto &u : users)
|
||||
{
|
||||
res += u.second.log.data.size();
|
||||
|
|
|
|||
21
src/user.cpp
21
src/user.cpp
|
|
@ -27,17 +27,24 @@ User::User(uint32_t init_bal, XXH64_hash_t init_pass, const Json::Value &log_j)
|
|||
{
|
||||
if (log_j.size())
|
||||
{
|
||||
#if MAX_LOG_SIZE != 1
|
||||
log.data.reserve(std::min((size_t)PRE_LOG_SIZE * ((log_j.size() / PRE_LOG_SIZE) + 1), (size_t)MAX_LOG_SIZE));
|
||||
#endif
|
||||
for (uint32_t i = (log_j.size() - MAX_LOG_SIZE) * (log_j.size() > MAX_LOG_SIZE); i < log_j.size(); i++)
|
||||
{
|
||||
log.data.push_back(Transaction(
|
||||
log_j[i]["from"].asCString(),
|
||||
log_j[i]["to"].asCString(),
|
||||
log_j[i]["amount"].asUInt(),
|
||||
#ifdef _USE_32BIT_TIME_T
|
||||
log_j[i]["time"].asUInt()));
|
||||
#if MAX_LOG_SIZE == 1
|
||||
log.data = (
|
||||
#else
|
||||
log_j[i]["time"].asUInt64()));
|
||||
log.data.push_back(
|
||||
#endif
|
||||
Transaction(
|
||||
log_j[i]["from"].asCString(),
|
||||
log_j[i]["to"].asCString(),
|
||||
log_j[i]["amount"].asUInt(),
|
||||
#ifdef _USE_32BIT_TIME_T
|
||||
log_j[i]["time"].asUInt()));
|
||||
#else
|
||||
log_j[i]["time"].asUInt64()));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue