Skip to content

Commit

Permalink
Tokens are not redeemed for viewed Ads at server side when passing --…
Browse files Browse the repository at this point in the history
…rewards=debug=true command-line arg

Fixes brave/brave-browser#4186
  • Loading branch information
tmancey authored Apr 23, 2019
1 parent 185dbf7 commit 523ef68
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
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

0 comments on commit 523ef68

Please sign in to comment.