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

CoinJoiClient.CreateRegisterAndConfirmCoinsAsync refactor #12947

Closed
wants to merge 1 commit into from

Conversation

csiki2
Copy link
Collaborator

@csiki2 csiki2 commented Apr 29, 2024

Moving the RegisterInputAsync function from the method.
Contributes to #12790 (comment)

Moving the RegisterInputAsync function from the method.
Contributes to zkSNACKs#12790 (comment)
Copy link
Collaborator

@molnard molnard left a comment

Choose a reason for hiding this comment

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

It is hard to review. It seems to me some variables got moved away to another class. By itself this is just an extra layer and adding more code plus deepening the references. Can you elaborate more on the concept what are you trying to achieve with this step?

@csiki2
Copy link
Collaborator Author

csiki2 commented Apr 30, 2024

Currently we had an oversized "lambda" (RegisterInputAsync) in a big method (CreateRegisterAndConfirmCoinsAsync) with huge amount of disposable "local variables" that is very hard to read on the first place (for example what is used in the lambda and what's not).
The change itself is pretty straight forward: the used variables went to a disposable class and the RegisterInputAsync became a proper method with the extra input parameter.
Practically this is a prerequisite to add the feature since I will need to work on these (after the change) methods.

Copy link
Collaborator

@molnard molnard left a comment

Choose a reason for hiding this comment

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

I got it. Basically you separated RegisterInputAsync method plus added an extra class for all the variables. It is a bit unusual to me but I saw the number of CancellationTokenSources that would have been needed to pass down to the method and it makes sense.

Copy link
Collaborator

@lontivero lontivero left a comment

Choose a reason for hiding this comment

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

NACK

If we agree with the problem as it is stated then the cleaner, easiest and more obvious solution is not to create a new type/abstraction but simply refactor the method:

The lambda (local function) can be moved/promoted as a class method. That method can receive the values that it needs instead of using the free variables.

@csiki2
Copy link
Collaborator Author

csiki2 commented May 2, 2024

You make my work terribly difficult. Originally I wanted to add these whole class as an inside class, but David suggested to make it into a single file.
Now you state that having 8 using line is healthy and "only" the lambda should be moved.
I have already changes on top of this.
NVM, I create a completely new pull request without any cleanup.

@csiki2 csiki2 closed this May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants