-
Notifications
You must be signed in to change notification settings - Fork 463
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
Replace chain store's headEvents "pubsub" with a synchronous event bus #2309
Comments
anorth
added
C-technical-debt
help wanted
Call for participation: More complex than good-first-issue
labels
Mar 18, 2019
Libp2p have produced a local event bus, see libp2p/go-libp2p#653. On my first reading, it seems to involve mandatory channels (and hence asynchrony), but worth investigating. |
The ugly |
anorth
removed
the
help wanted
Call for participation: More complex than good-first-issue
label
Aug 22, 2019
4 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
The chain store carries a
headEvents
reference which is a channel-based "pubsub" object from https://github.com/cskr/pubsub. The object supports notification of when a new head tipset is discovered.The asynchrony forced by using channels complicates, things, and in particular has led to a mutable
HeaviestTipSetHandled
callback func on the Node purely so thatnode.TestUpdateMessagePool
can tell when the subscriber to that pubsub has finished.Forcing the use of channels here unnecessary. This use would be much better served by a simple, synchronous event bus like this one. The message pool test could then simply update the head and know that the node has responded when the event post returns.
Note that this pattern doesn't prevent asynchrony for any particular event/subscriber, but makes it opt-in. Reducing unnecessary concurrency, and scoping it tightly, could also help us avoid work and/or headaches of handing concurrency in objects that are transitively reachable from any goroutine (we almost certainly don't handle this properly at present).
Since an event bus is a relatively simple pattern, I suggest we write our own, a simpler version of that linked above. We can then limit & customise functionality to exactly our needs. I expect an event bus will be useful for more than this single use case.
Acceptance criteria
Node.HeaviestTipSetHandled
is removedgithub.com/cskr/pubsub
is removed from dependenciesRisks + pitfalls
Context
, but we shouldWhere to begin
In
node.go
, understand usage ofHeaviestTipSetCh
andHeaviestTipSetHandled
.The text was updated successfully, but these errors were encountered: