simplewallet: randomize pause_time for each churn

This commit is contained in:
fuwa 2019-05-24 22:13:00 +08:00
parent 4abfc23006
commit c73c7abfcd

View file

@ -9372,8 +9372,15 @@ bool simple_wallet::churn(const std::vector<std::string> &args_)
int churn_number, pause_time, i; int churn_number, pause_time, i;
srand (time(NULL)); // seed RNG with current time srand (time(NULL)); // seed RNG with current time
churn_number = rand()%(8 + 1 - 2) + 2; // churn between 2 to 8 times churn_number = rand()%(8 + 1 - 2) + 2; // churn between 2 to 8 times
std::stack<int> pauses;
float total_time = 0;
// no pause for the last churn
for (i = 1; i <= churn_number - 1; ++i) {
pause_time = rand()%(120 + 1 - 60) + 60; // wait between 1 to 2 hours per interval pause_time = rand()%(120 + 1 - 60) + 60; // wait between 1 to 2 hours per interval
float total_time = static_cast<float>(churn_number*pause_time)/60; // calculate how long churning will take in hours pauses.push(pause_time);
total_time += static_cast<float>(pause_time)/60; // calculate how long churning will take in hours
}
// Calculate fee // Calculate fee
float churn_fee = m_wallet->use_fork_rules(HF_VERSION_PER_BYTE_FEE) ? static_cast<float>(churn_number * 0.015) : static_cast<float>(churn_number * 0.032654); // usual 2/2 tx fee float churn_fee = m_wallet->use_fork_rules(HF_VERSION_PER_BYTE_FEE) ? static_cast<float>(churn_number * 0.015) : static_cast<float>(churn_number * 0.032654); // usual 2/2 tx fee
@ -9420,7 +9427,8 @@ bool simple_wallet::churn(const std::vector<std::string> &args_)
else else
{ {
message_writer() << tr("\nInterval pause, please wait...\n"); message_writer() << tr("\nInterval pause, please wait...\n");
sleep(pause_time*60); sleep(pauses.top()*60);
pauses.pop();
} }
} }