mirror of
https://github.com/Expand-sys/CCash
synced 2025-12-16 00:02:14 +11:00
🔥 removed MAX_LOG_SIZE == 1 specific case
This commit is contained in:
parent
8d52d8f5e3
commit
5bc3511c43
2 changed files with 0 additions and 18 deletions
|
|
@ -15,11 +15,7 @@ private:
|
|||
std::string log_snapshot = "null";
|
||||
|
||||
public:
|
||||
#if MAX_LOG_SIZE == 1
|
||||
Transaction data;
|
||||
#else
|
||||
std::deque<Transaction> data;
|
||||
#endif
|
||||
|
||||
std::string GetLogs() noexcept;
|
||||
void AddTrans(const std::string &from, const std::string &to, uint32_t amount, time_t time) noexcept;
|
||||
|
|
|
|||
14
src/log.cpp
14
src/log.cpp
|
|
@ -3,15 +3,11 @@
|
|||
void Log::AddTrans(const std::string &from, const std::string &to, uint32_t amount, time_t time) noexcept
|
||||
{
|
||||
log_flag.SetChangesOn();
|
||||
#if MAX_LOG_SIZE == 1
|
||||
data = std::move(Transaction(from, to, amount, time));
|
||||
#else
|
||||
if (data.size() == MAX_LOG_SIZE)
|
||||
{
|
||||
data.pop_back();
|
||||
}
|
||||
data.emplace_back(from, to, amount, time);
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string Log::GetLogs() noexcept
|
||||
|
|
@ -47,15 +43,6 @@ std::string Log::GetLogs() noexcept
|
|||
Json::Value Log::Serialize() const
|
||||
{
|
||||
Json::Value res;
|
||||
#if MAX_LOG_SIZE == 1
|
||||
res[0]["to"] = data.to;
|
||||
res[0]["from"] = data.from;
|
||||
#ifdef _USE_32BIT_TIME_T
|
||||
res[0]["time"] = (Json::UInt)data.time;
|
||||
#else
|
||||
res[0]["time"] = (Json::UInt64)data.time;
|
||||
#endif
|
||||
#else
|
||||
for (uint32_t i = 0; i < data.size(); ++i)
|
||||
{
|
||||
res[i]["to"] = data[i].to;
|
||||
|
|
@ -67,6 +54,5 @@ Json::Value Log::Serialize() const
|
|||
res[i]["time"] = (Json::Int64)data[i].time;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
return res;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue