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

WIP: Rework block notification #92

Merged
merged 1 commit into from
Nov 10, 2023
Merged

WIP: Rework block notification #92

merged 1 commit into from
Nov 10, 2023

Conversation

Davidson-Souza
Copy link
Collaborator

Currently, if a module wants to get blocks as they are accepted, they should pass in a channel to chainstate and pool this channel for new blocks. That works fine for services (i.e: modules that have a loop watching stuff happening) but some modules might not be services, like the filters backend introduced in #89. This PR changes the subscription logic to "pass in an Arc-ed object that implements BlockConsumer".

It also implements a Sync + Send + 'static channel that depends solely on alloc, and implements BlockConsumer. The std mspc channel receiver isn't Send, making it tricky to use it across await points; using channels from async-std::channel adds the function coloring problem to the notification mechanism, which is undesirable. Moreover, we only need to send data from one source (ChainState) to one consumer (whoever wants to be notified), therefore a single source, single consumer channel is a perfect fit.

@Davidson-Souza Davidson-Souza merged commit ee1fcec into master Nov 10, 2023
11 checks passed
@Davidson-Souza Davidson-Souza deleted the remove-channel branch January 8, 2024 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant