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

core: use buffered ch for subscription #30350

Closed
wants to merge 1 commit into from

Conversation

ceyonur
Copy link
Contributor

@ceyonur ceyonur commented Aug 24, 2024

After the refactor the channel changed from buffered to unbuffered. The comment said Buffered to avoid locking up the event feed, if that's the case (it seems like can be) should the channel be kept buffered and even with the the buffer capacity >1?

@rjl493456442
Copy link
Member

rjl493456442 commented Aug 26, 2024

The buffer channel is unnecessary.

Once the event is emitted via the channel, it will be consumed very quickly.
In the code snippet below, the event will try to spin up a background indexer
if it was not active, and then update some internal flags. The whole procedure
is regarded very fast and very unlikely to block the feed.

In another word, if the event consumer is very slow, the feed will be blocked
anyway theoretically no matter what the size is.

		case head := <-headCh:
			if done == nil {
				stop = make(chan struct{})
				done = make(chan struct{})
				go indexer.run(rawdb.ReadTxIndexTail(indexer.db), head.Block.NumberU64(), stop, done)
			}
			lastHead = head.Block.NumberU64()

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.

2 participants