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

refactor: clean up channel creation #407

Merged
merged 2 commits into from
Sep 26, 2023
Merged

refactor: clean up channel creation #407

merged 2 commits into from
Sep 26, 2023

Conversation

alex-miao
Copy link
Collaborator

Closes #356

Proposed Changes

  • Move channel creation to within cli

@@ -221,7 +223,7 @@ enum ServerRequestKind {
}

#[derive(Debug)]
struct ServerRequest {
pub struct ServerRequest {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any thoughts on workarounds to avoid making this public?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets just pass in the capacity like it was setup before.

@@ -69,7 +71,7 @@ impl Task for PoolTask {
};
let provider = eth::new_provider(&self.args.http_url, self.args.http_poll_interval)?;
let chain = Chain::new(provider, chain_settings);
let (update_sender, _) = broadcast::channel(1000);
let (update_sender, _) = broadcast::channel(CHAIN_UPDATE_CHANNEL_CAPACITY);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought about making this one a function param but would break the run function signature for the trait.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think at a minimum we should pass in CHAIN_UPDATE_CHANNEL_CAPACITY via Args

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @dancoombs passing it as an argument with a default value

@alex-miao
Copy link
Collaborator Author

Wasn't sure how to/if I should refactor some of the other places with channel creation, so let me know if this is incomplete.

Comment on lines 30 to 31
req_sender: mpsc::Sender<ServerRequest>,
req_receiver: mpsc::Receiver<ServerRequest>,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I actually think for this one its fine to just pass in the capacity, hides the actual message passing mechanism from the interface.

@@ -30,9 +30,11 @@ pub struct LocalPoolBuilder {

impl LocalPoolBuilder {
/// Create a new local pool server builder
pub fn new(request_capacity: usize, block_capacity: usize) -> Self {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I like the old implementation better than having to expose the internals of how the local pool actor passes messages. I think just exposing the capacities is fine here.

Copy link
Collaborator

@dancoombs dancoombs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After seeing this implementation, I think its best to just expose the capacities as configuration variables on the tasks/structs, and then pass those from constants defined in bin. Much better than having to expose these internal types.

Copy link
Collaborator

@0xfourzerofour 0xfourzerofour left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@@ -69,7 +71,7 @@ impl Task for PoolTask {
};
let provider = eth::new_provider(&self.args.http_url, self.args.http_poll_interval)?;
let chain = Chain::new(provider, chain_settings);
let (update_sender, _) = broadcast::channel(1000);
let (update_sender, _) = broadcast::channel(CHAIN_UPDATE_CHANNEL_CAPACITY);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @dancoombs passing it as an argument with a default value

@alex-miao alex-miao merged commit aca20b2 into main Sep 26, 2023
6 checks passed
@alex-miao alex-miao deleted the alex/channels branch September 26, 2023 00:49
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.

all: Clean up channel creation and size
3 participants