19 lines
300 B
Go
19 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
|
|
}
|