Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: dirkmc <dirkmdev@gmail.com>
  • Loading branch information
hannahhoward and dirkmc committed Dec 2, 2022
1 parent be79b05 commit 3ab025d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions cmd/booster-bitswap/filters/filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func (mf *MultiFilter) Start(ctx context.Context) error {
// if the file does not exist, synchronously fetch the list
if err != nil {
if !os.IsNotExist(err) {
return fmt.Errorf("fetching badbits list: %w", err)
return fmt.Errorf("fetching filter list: %w", err)
}
err = f.update()
if err != nil {
Expand Down Expand Up @@ -189,6 +189,7 @@ func (mf *MultiFilter) run(cachedCopies []bool) {
}
}
updater := mf.clock.Ticker(UpdateInterval)
defer updater.Stop()
// call the callback if set
if mf.onTimerSet != nil {
mf.onTimerSet()
Expand All @@ -198,7 +199,7 @@ func (mf *MultiFilter) run(cachedCopies []bool) {
case <-mf.ctx.Done():
return
case <-updater.C:
// when timer expires, update deny list
// when timer expires, update filters
for _, f := range mf.filters {
err := f.update()
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions cmd/booster-bitswap/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ func (s *BitswapServer) Start(ctx context.Context, proxy *peer.AddrInfo) error {
}
bsopts := []server.Option{server.MaxOutstandingBytesPerPeer(1 << 20), server.WithPeerBlockRequestFilter(func(p peer.ID, c cid.Cid) bool {
fulfill, err := s.filter.FulfillRequest(p, c)
// peer request block filter expects a true if the request should be fulfilled, so
// we only return true for cids that aren't filtered and have no errors
// peer request filter expects a true if the request should be fulfilled, so
// we only return true for requests that aren't filtered and have no errors
return fulfill && err == nil
})}
net := bsnetwork.NewFromIpfsHost(host, nilRouter)
Expand Down

0 comments on commit 3ab025d

Please sign in to comment.