-
Notifications
You must be signed in to change notification settings - Fork 81
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
blockchain: subscriptions API refactoring #3281
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3281 +/- ##
==========================================
+ Coverage 85.14% 85.22% +0.07%
==========================================
Files 327 327
Lines 44437 44412 -25
==========================================
+ Hits 37836 37850 +14
+ Misses 5098 5057 -41
- Partials 1503 1505 +2 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good, we also have notary request subscriptions with the same problem.
Let's move this PR and issue to 0.106.0, it's not critical.
0fa749b
to
e7b3d73
Compare
e7b3d73
to
a4d79f7
Compare
There is no need to accept rw channel. Strengthening the type to send-only will allow the caller to ensure control of reading from the provided channel. Closes #2885 Signed-off-by: Ekaterina Pavlova <[email protected]>
a4d79f7
to
e337a2f
Compare
func (bc *Blockchain) UnsubscribeFromBlocks(ch chan *block.Block) { | ||
unsubloop: | ||
for { | ||
select { | ||
case <-ch: | ||
case bc.unsubCh <- ch: | ||
break unsubloop | ||
} | ||
} | ||
func (bc *Blockchain) UnsubscribeFromBlocks(ch chan<- *block.Block) { | ||
bc.unsubCh <- ch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, that's the case @roman-khimov told about in #2884 (comment). We can't remove this unsubloop
code, because starting from the unsubscription moment all data sent to this channel should be discarded.
Since unsubscription interface doesn't allow send-only channel to be passed as an argument ( |
make (Blockchain).SubscribeFor arguments
chan<-
as a send-only channel. Originally #2884