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

blockservice: fix panic when closing an offline blockservice #533

Merged
merged 1 commit into from
Jan 4, 2024

Conversation

Jorropo
Copy link
Contributor

@Jorropo Jorropo commented Jan 3, 2024

blockservice is explicitely tolerent to having a nil exchange. The constructor even logs that as running an offline blockservice.

Everything is tolerent 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.

blockservice is explicitely tolerent to having a nil exchange.
The constructor even logs that as running an offline blockservice.

Everything is tolerent 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.
@Jorropo Jorropo requested a review from a team as a code owner January 3, 2024 17:50
Copy link

codecov bot commented Jan 3, 2024

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (a001f98) 65.53% compared to head (fabc515) 65.61%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #533      +/-   ##
==========================================
+ Coverage   65.53%   65.61%   +0.08%     
==========================================
  Files         207      207              
  Lines       25559    25562       +3     
==========================================
+ Hits        16750    16773      +23     
+ Misses       7337     7318      -19     
+ Partials     1472     1471       -1     
Files Coverage Δ
blockservice/blockservice.go 76.25% <0.00%> (-0.84%) ⬇️

... and 13 files with indirect coverage changes

@hacdias hacdias merged commit 79cace5 into main Jan 4, 2024
13 of 14 checks passed
@hacdias hacdias deleted the fix-offline-blockservice branch January 4, 2024 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants