Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bitswap move providing responsabilities from the server to blockservice & reprovider #528

Closed
wants to merge 6 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
blockservice: fix panic when closing an offline blockservice
blockservice is explicitely tolerent to having a nil exchange.
The constructor even logs that as running an offline blockservice.

Everything is except close, which panics.

It is confusing for consumers to only have to call close based on if it's online or offline.
They could also instead call close directly on the exchange (then we could remove blockservice's Close method).

Anyway here is as a simple fix, add a nil check.
  • Loading branch information
Jorropo committed Dec 29, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 4bfdb6b40182dfb67d31c63f3c84077972e73e36
3 changes: 3 additions & 0 deletions blockservice/blockservice.go
Original file line number Diff line number Diff line change
@@ -478,6 +478,9 @@ func (s *blockService) DeleteBlock(ctx context.Context, c cid.Cid) error {

func (s *blockService) Close() error {
logger.Debug("blockservice is shutting down...")
if s.exchange == nil {
return nil
}
return s.exchange.Close()
}