mirror of
https://github.com/Expand-sys/CCash
synced 2026-03-22 12:37:08 +11:00
Code comments for logs
This commit is contained in:
parent
a2287a4d36
commit
af51335aa7
1 changed files with 6 additions and 5 deletions
|
|
@ -9,17 +9,18 @@ struct Log
|
|||
std::vector<Transaction> data;
|
||||
void AddTrans(Transaction &&t)
|
||||
{
|
||||
if (data.size() == max_log_size)
|
||||
if (data.size() == max_log_size) // If we hit the max size
|
||||
{
|
||||
for (auto i = data.size() - 1; i > 0; i--)
|
||||
for (auto i = data.size() - 1; i > 0; i--) // Make room at the back
|
||||
{
|
||||
data[i - 1] == std::move(data[i])
|
||||
}
|
||||
}
|
||||
else if (data.size() == data.capacity()) {
|
||||
data.reserve(data.capacity() + pre_alloc)
|
||||
else if (data.size() == data.capacity()) // If we haven't hit the max but hit capacity
|
||||
{
|
||||
data.reserve(data.capacity() + pre_alloc) // Reserve more memory
|
||||
}
|
||||
data[data.size() - 1] = std::move(t)
|
||||
data[data.size() - 1] = std::move(t) // In any case, place new at the back
|
||||
}
|
||||
Json::Value Serialize() const
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue