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

Drop unnecessary int reference in SCID conversion utilities #2908

Merged
merged 1 commit into from
Feb 22, 2024

Conversation

TheBlueMatt
Copy link
Collaborator

No description provided.

Copy link

coderabbitai bot commented Feb 21, 2024

Walkthrough

The changes primarily focus on simplifying code interactions with u64 values across different files. By removing unnecessary references when passing u64 values in function calls, the code becomes cleaner and more direct. This adjustment spans from updating function signatures to altering call sites, ensuring that u64 values are passed directly, enhancing readability and efficiency.

Changes

File(s) Summary
.../ln/monitor_tests.rs, .../scid_utils.rs Removed unnecessary references for u64 in function calls and updated function signatures.
.../routing/gossip.rs Added dereference in block_from_scid call to correctly calculate block difference.

🐇✨
In the realm of code, where the bits align,
A rabbit hopped, making the logic fine.
"No more references, let's be direct,"
It said, as it made the code perfect.
With a hop, a skip, in the digital glade,
It left the code cleaner, improvements made.
🌟🐾

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 2964751 and 0cd353c.
Files selected for processing (3)
  • lightning/src/ln/monitor_tests.rs (3 hunks)
  • lightning/src/routing/gossip.rs (1 hunks)
  • lightning/src/util/scid_utils.rs (4 hunks)
Files not reviewed due to errors (1)
  • lightning/src/routing/gossip.rs (Error: unable to parse review)
Files skipped from review due to trivial changes (1)
  • lightning/src/ln/monitor_tests.rs
Additional comments: 6
lightning/src/util/scid_utils.rs (6)
  • 36-36: The change to block_from_scid to accept a u64 directly instead of a reference simplifies the function call and eliminates the need for dereferencing. This is a positive change that aligns with the PR's objectives of improving code readability and potentially enhancing performance.
  • 41-41: The update to tx_index_from_scid to directly use a u64 parameter instead of a reference is consistent with the goal of streamlining the code. This modification enhances the function's simplicity and readability.
  • 46-46: Modifying vout_from_scid to accept a u64 directly rather than a reference is in line with the PR's aim to simplify function signatures. This change contributes to cleaner and more straightforward code.
  • 165-170: The logic within is_valid_phantom and is_valid_intercept functions appears sound, correctly utilizing the updated block_from_scid, tx_index_from_scid, and vout_from_scid functions. However, it's important to ensure that all calls to these functions elsewhere in the codebase have been updated to pass u64 values directly, in line with these changes.

Also applies to: 175-180

Verification successful

The verification process, based on the shell script output, confirms that there are no remaining references to the old function signatures for block_from_scid, tx_index_from_scid, and vout_from_scid functions. This suggests that all calls to these functions have been updated to pass u64 values directly, in line with the changes mentioned in the review comment. Therefore, the concern raised in the review comment has been addressed.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for any remaining references to the old function signatures.
rg --type rust 'block_from_scid\(&' || echo "No old references found."
rg --type rust 'tx_index_from_scid\(&' || echo "No old references found."
rg --type rust 'vout_from_scid\(&' || echo "No old references found."

Length of output: 292

* 251-258: The tests in the `fake_scid` module correctly use the updated function signatures for `block_from_scid`, `tx_index_from_scid`, and `vout_from_scid`. This ensures that the tests remain valid and effective after the changes. It's good practice to verify that all relevant tests have been updated or added to cover the new logic. * 270-292: The unit tests for `block_from_scid`, `tx_index_from_scid`, and `vout_from_scid` functions are comprehensive, covering a range of input values to ensure correctness. It's commendable that tests have been included or updated to reflect the changes in function signatures. This helps maintain high code quality and reliability.

@tnull
Copy link
Contributor

tnull commented Feb 22, 2024

Seems trivial, so not waiting for a second reviewer.

@tnull tnull merged commit affe557 into lightningdevkit:main Feb 22, 2024
14 of 15 checks passed
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