Skip to content

Commit

Permalink
update lazymap
Browse files Browse the repository at this point in the history
add rate limitting for NotFound
  • Loading branch information
vintikzzz committed Dec 17, 2024
1 parent b3ca0b3 commit f667670
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions services/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ func (s *Store) getRate(h string) *atomic.Int64 {

func (s *Store) touch(ctx context.Context, h string) (ok bool, err error) {
if !s.checkRate(h) {
s.incRate(h)
log.WithField("infohash", h).Warn("get rate limit")
return false, ErrNotFound
}
Expand Down Expand Up @@ -128,6 +129,7 @@ func (s *Store) touch(ctx context.Context, h string) (ok bool, err error) {

func (s *Store) pull(ctx context.Context, h string, start int) (torrent []byte, err error) {
if !s.checkRate(h) {
s.incRate(h)
log.WithField("infohash", h).Warn("get rate limit")
return nil, ErrNotFound
}
Expand Down

0 comments on commit f667670

Please sign in to comment.