diff --git a/common.go b/common.go index d76d38e..8cd7f91 100644 --- a/common.go +++ b/common.go @@ -539,7 +539,7 @@ const ( type LimitFallback struct { AfterBytes int64 - BytesPerSec float64 + BytesPerSec int64 BurstBytesPerSec int64 } diff --git a/tls.go b/tls.go index 0603a2b..bbe0ec4 100644 --- a/tls.go +++ b/tls.go @@ -43,7 +43,6 @@ import ( "errors" "fmt" "io" - "math" "net" "os" "runtime" @@ -120,11 +119,11 @@ func (c *RatelimitedConn) Write(b []byte) (int, error) { return n, err } -func NewBucketWithRate(bytesPerSec float64, burstBytesPerSec int64) *ratelimit.Bucket { - if burstBytesPerSec < int64(math.Ceil(bytesPerSec)) { - burstBytesPerSec = int64(math.Ceil(bytesPerSec)) +func NewBucketWithRate(bytesPerSec int64, burstBytesPerSec int64) *ratelimit.Bucket { + if burstBytesPerSec < bytesPerSec { + burstBytesPerSec = bytesPerSec } - return ratelimit.NewBucketWithRate(bytesPerSec, burstBytesPerSec) + return ratelimit.NewBucketWithRate(float64(bytesPerSec), burstBytesPerSec) } var (