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

go-kosu: update scaling methods to be consistent #243

Merged
merged 7 commits into from Aug 29, 2019
Next

go-kosu: use pointer types in poster limit

  • Loading branch information
hrharder committed Aug 28, 2019
commit 4fe66115eddd9241d6a54249e26762bce963deed
@@ -77,15 +77,15 @@ func posterIterator(app *App, totalBalance *big.Int) func(string, *types.Poster)
// calculates a poster's period limit based on their balance and the total poster balance
func posterLimit(periodLimit uint64, posterBalance, totalBalance *big.Int) uint64 {
// copy periodLimit (pl), posterBalance (pb), totalBalance (tb)
var pl, pb, tb big.Int
var pl, pb, tb *big.Int
pl.SetUint64(periodLimit)
pb.Set(posterBalance)
tb.Set(totalBalance)

// limit = (posterBalance / totalBalance) * periodLimit
limit := big.NewInt(0)
limit.Mul(&pl, &pb)
limit.Div(limit, &tb)
limit.Mul(pl, pb)
limit.Div(limit, tb)

if !limit.IsUint64() {
return math.MaxUint64
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.