Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tokens are not redeemed for viewed Ads at server side when passing --rewards=debug=true command-line arg 0.64.x #2302

Merged
merged 1 commit into from
Apr 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -883,26 +883,16 @@ void ConfirmationsImpl::RefillTokensIfNecessary() const {
}

uint64_t ConfirmationsImpl::CalculateTokenRedemptionTimeInSeconds() {
auto now_in_seconds = Time::NowInSeconds();

uint64_t start_timer_in;

if (_is_debug) {
if (next_token_redemption_date_in_seconds_ - now_in_seconds >=
kDebugNextTokenRedemptionAfterSeconds) {
UpdateNextTokenRedemptionDate();
SaveState();
}
}

if (next_token_redemption_date_in_seconds_ == 0) {
UpdateNextTokenRedemptionDate();
SaveState();
}

auto now_in_seconds = Time::NowInSeconds();

uint64_t start_timer_in;
if (now_in_seconds >= next_token_redemption_date_in_seconds_) {
// Browser was launched after the token redemption date
start_timer_in = base::RandInt(0, 5 * base::Time::kSecondsPerMinute);
start_timer_in = base::RandInt(0, 1 * base::Time::kSecondsPerMinute);
} else {
start_timer_in = next_token_redemption_date_in_seconds_ - now_in_seconds;
}
Expand All @@ -923,6 +913,8 @@ void ConfirmationsImpl::UpdateNextTokenRedemptionDate() {
next_token_redemption_date_in_seconds_ +=
kDebugNextTokenRedemptionAfterSeconds;
}

SaveState();
}

void ConfirmationsImpl::StartRetryingFailedConfirmations(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ void PayoutTokens::OnPayout(const Result result) {

void PayoutTokens::ScheduleNextPayout() const {
confirmations_->UpdateNextTokenRedemptionDate();
confirmations_->SaveState();

auto start_timer_in = confirmations_->CalculateTokenRedemptionTimeInSeconds();
confirmations_->StartPayingOutRedeemedTokens(start_timer_in);
Expand Down