🐛 real max log size is 59 not 60

This commit is contained in:
EntireTwix 2021-07-29 20:53:53 -07:00
parent 4cfc27e01e
commit 96d3c1de08
2 changed files with 2 additions and 3 deletions

View file

@ -75,7 +75,7 @@ int main(int argc, char **argv)
size_t num_of_logs = Bank::NumOfLogs(); size_t num_of_logs = Bank::NumOfLogs();
size_t num_of_users = Bank::NumOfUsers(); size_t num_of_users = Bank::NumOfUsers();
std::cout << "\n\nLoaded " << num_of_users << " Users ~" << (float)(sizeof(User) * num_of_users) / 1048576 << "Mb" std::cout << "\n\nLoaded " << num_of_users << " Users ~" << (float)(sizeof(User) * num_of_users) / 1048576 << "Mb"
<< "\nLoaded " << num_of_logs << " Logs ~" << (float)(num_of_logs * (90 + 80 + (max_name_size * 2))) / 1048576 << "Mb" //90:string representation(heap), sizeof(Transaction), max_name_size*2:filled to&from(heap) << "\nLoaded " << num_of_logs << " Logs ~" << (float)(num_of_logs * (91 + 80 + (max_name_size * 2))) / 1048576 << "Mb" //91:string representation(heap), sizeof(Transaction), max_name_size*2:filled to&from(heap)
<< "\nLoaded " << Bank::SumBal() << " CSH" << "\nLoaded " << Bank::SumBal() << " CSH"
<< std::endl; //flushing before EventLoop << std::endl; //flushing before EventLoop

View file

@ -15,8 +15,7 @@ std::string Log::GetLogs() noexcept
if (log_flag.GetChangeState() && data.size()) //if there are changes if (log_flag.GetChangeState() && data.size()) //if there are changes
{ {
//re-generate snapshot //re-generate snapshot
//({\"amount\":1,\"from\":\"\",\"time\":1625943626,\"to\":\"\"}, + (2*max_name_size)+10+10) * # of logs) + 1 size_t predicted_size = ((59 + (2 * max_name_size)) * data.size()) + 1;
size_t predicted_size = ((60 + (2 * max_name_size)) * data.size()) + 1;
if (log_snapshot.capacity() < predicted_size) if (log_snapshot.capacity() < predicted_size)
{ {
log_snapshot.reserve(predicted_size); log_snapshot.reserve(predicted_size);