-
Notifications
You must be signed in to change notification settings - Fork 900
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
Fixes AC for 1min setting #1507
Conversation
49da6f6
to
80d43de
Compare
1d0f707
to
f14a068
Compare
801433c
to
d735b7f
Compare
uint64_t min_duration_ms = min_duration * | ||
braveledger_ledger::_milliseconds_second; | ||
a_ = (1.0 / (braveledger_ledger::_d * 2.0)) - min_duration_ms; | ||
uint64_t min_duration_big = min_duration * 100; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we needed to reduce this from 1000 to 100 as we were hitting limit and getting nan
. We still multiply it with 100 to keep precision
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused, are you talking about the JS side? Presumably multiplying by 1000 was for ms, so why would we multiply by 100?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct 1000 was for ms. If we remove multiply completely formula is not that efficient anymore, so that's why we still multiply it with 100 to have better results
b2_ = b_ * b_; | ||
} | ||
|
||
// courtesy of @dimitry-xyz: https://github.com/brave/ledger/issues/2#issuecomment-221752002 | ||
double BatPublishers::concaveScore(const uint64_t& duration) { | ||
uint64_t duration_ms = duration * braveledger_ledger::_milliseconds_second; | ||
return (-b_ + std::sqrt(b2_ + (a4_ * duration_ms))) / a2_; | ||
uint64_t duration_big = duration * 100; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
29a4bea
to
0890027
Compare
0890027
to
c83662f
Compare
@@ -431,6 +430,7 @@ void BatPublishers::OnRestorePublishersInternal(bool success) { | |||
|
|||
void BatPublishers::setPublisherMinVisitTime(const uint64_t& duration) { // In seconds | |||
state_->min_publisher_duration_ = duration; | |||
calcScoreConsts(duration); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to update variables on the fly and not only when we restart the browser
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should really move these things to an observer for PublisherMinVisitTime change in a follow-up somewhere
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so ledger would save data and call rewards that save was successful and we would trigger observer that would then call back ledger?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, an observer internal to ledger
@@ -607,7 +607,7 @@ static bool ignore_ = false; | |||
allow_videos_ = state.allow_videos_; | |||
monthly_balances_ = state.monthly_balances_; | |||
recurring_donation_ = state.recurring_donation_; | |||
migrate_score = state.migrate_score; | |||
migrate_score_2 = state.migrate_score_2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
score_2?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so we migrated once already and we just need to migrate it again, so that's why I rename it to 2 as 1 is not needed anymore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but why does it need to be score_2 in the data structure?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so that we migrate only once
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, the name has changed now, but I think what we need here is a version
attribute for the data
ac33f6a
to
7fe7e3f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
7fe7e3f
to
20ff2b5
Compare
Resolves brave/brave-browser#3320
Submitter Checklist:
npm test brave_unit_tests && npm test brave_browser_tests
) ongit rebase master
(if needed).git rebase -i
to squash commits (if needed).Test Plan:
Reviewer Checklist: