8000 feat(p2p): create `NetworkExt` trait for default P2P port and `Magic` values by luisschwab · Pull Request #4639 · rust-bitcoin/rust-bitcoin · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat(p2p): create NetworkExt trait for default P2P port and Magic values #4639

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

luisschwab
Copy link
Contributor

Closes #4632.

This PR introduces the NetworkExt trait that extends Network with getters for default P2P port and network magic bytes.

Changelog

  • Create NetworkExt trait.
  • Implement get_p2p_port for Network.
  • Implement get_network_magic for Network.

@github-actions github-actions bot added the C-p2p label Jun 25, 2025
@coveralls
Copy link

Pull Request Test Coverage Report for Build 15868329799

Details

  • 43 of 45 (95.56%) changed or added relevant lines in 1 file are covered.
  • 6 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.003%) to 84.249%

Changes Missing Coverage Covered Lines Changed/Added Lines %
p2p/src/network_ext.rs 43 45 95.56%
Files with Coverage Reduction New Missed Lines %
bitcoin/src/psbt/mod.rs 6 87.22%
Totals Coverage Status
Change from base Build 15857094248: -0.003%
Covered Lines: 23599
Relevant Lines: 28011

💛 - Coveralls

/// The default P2P port for a given [`Network`].
fn get_p2p_port(&self) -> u16;
/// The default [`Magic`] for a given [`Network`].
fn get_network_magic(&self) -> Magic;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is covered by from_params on Magic

/// Trait that extends [`Network`] by adding getter methods for the default P2P ports and [`Magic`] bytes.
pub trait NetworkExt {
/// The default P2P port for a given [`Network`].
fn get_p2p_port(&self) -> u16;
Copy link
Contributor

Choose a reason for hiding this comment

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

Code style nit, I think we can drop the get prefix

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.

Add method to get the default P2P port for a Network
3 participants
0