mirror of
https://github.com/anyproto/any-sync.git
synced 2025-06-08 05:57:03 +09:00
18 lines
300 B
Go
18 lines
300 B
Go
package peer
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
type limiter struct {
|
|
startThreshold int
|
|
slowDownStep time.Duration
|
|
}
|
|
|
|
func (l limiter) wait(count int) <-chan time.Time {
|
|
if count > l.startThreshold {
|
|
wait := l.slowDownStep * time.Duration(count-l.startThreshold)
|
|
return time.After(wait)
|
|
}
|
|
return nil
|
|
}
|