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

[DO-NOT-MERGE] txpool: streamline initialisation #13202

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Conversation

taratorio
Copy link
Member

PR IS IN DRAFT (but want to run CI)

Attempt to simplify how we initialise and run theTxPool.

Observations:

  1. Currently the package exports many sub-components to backend.go such as Fetch, Sender, PoolDB, newTxs chan txpool.Announcements. I see these all as internal components of the TxPool that backend.go and other initialisers should not care about. In reality, the only things backend.go cares about are the TxPool and the TxPoolGrpcServer.
  2. Additionally, logic about starting and closing the tx pool leaks to backend.go (ie the creator of tx pool needs to know what sub-components need to be started and disposed).

This PR addresses the above by:

  1. Moving the p2p fetcher, sender and pool db as internal attributes of TxPool.
  2. Introducing the Run(ctx) pattern that we are using in Astrid and Shutter where each runnable component is responsible for starting its own background goroutines, loops, listeners, etc. and also is responsible for shutting them all down by being ctx-aware (ie when ctx is cancelled all sub components gets disposed of/shutdown)

@taratorio taratorio added the do-not-merge PR that is in a merge-able state but is waiting for something else to take place before merging label Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge PR that is in a merge-able state but is waiting for something else to take place before merging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant