Skip to content

Conversation

@Davidson-Souza
Copy link
Member

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
@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