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

suggestion to don't clone self in get_block #9044

Open
wants to merge 1 commit into
base: get-block
Choose a base branch
from

Conversation

oxarbitrage
Copy link
Contributor

Motivation

In #9006 we are cloning self in the get_block implementation which could bring some problems in some tests.

Solution

This is an alternative to do that that @conradoplg might find useful, feel free to discard.

@oxarbitrage oxarbitrage requested a review from a team as a code owner November 19, 2024 20:19
@oxarbitrage oxarbitrage requested review from arya2 and removed request for a team November 19, 2024 20:19
@mpguerra mpguerra requested review from conradoplg and removed request for arya2 November 20, 2024 08:45
Comment on lines +757 to +761
let get_block_header_future = if matches!(verbosity, 1 | 2) {
Some(self.get_block_header(original_hash_or_height.clone(), Some(true)))
} else {
None
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Optional/Nitpick/Subjective: This may actually be a little less readable, but it's tempting to use then() here.

Suggested change
let get_block_header_future = if matches!(verbosity, 1 | 2) {
Some(self.get_block_header(original_hash_or_height.clone(), Some(true)))
} else {
None
};
let get_block_header_future = matches!(verbosity, 1 | 2)
.then(|| self.get_block_header(original_hash_or_height.clone(), Some(true)));

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