Repository navigation
apollo_network_benchmark: moved peerID creation files #12725
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
Closed
sirandreww-starkware
wants to merge
1
commit into
02-18-apollo_network_benchmark_moved_metric_declerations_to_crate
from
02-18-apollo_network_benchmark_moved_peerid_creation_files
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| pub mod metrics; | ||
| pub mod node_args; | ||
| pub mod peer_key; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| use anyhow::Context; | ||
| use libp2p::identity::Keypair; | ||
|
|
||
| /// Derives a deterministic ed25519 private key from a node index. | ||
| /// The index is written as little-endian bytes into the first 8 bytes of a 32-byte seed. | ||
| pub fn private_key_from_node_id(node_id: u64) -> [u8; 32] { | ||
| let mut key = [0u8; 32]; | ||
| key[..8].copy_from_slice(&node_id.to_le_bytes()); | ||
| key | ||
| } | ||
|
|
||
| /// Returns the PeerId string for a given node index. | ||
| pub fn peer_id_from_node_id(node_id: u64) -> anyhow::Result<String> { | ||
| let secret_key_bytes = private_key_from_node_id(node_id); | ||
| let keypair = Keypair::ed25519_from_bytes(secret_key_bytes) | ||
| .context("Failed to derive keypair from node id")?; | ||
| Ok(keypair.public().to_peer_id().to_string()) | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New exported function
peer_id_from_node_idis unusedLow Severity
The newly added
peer_id_from_node_idfunction is exported (pub) but has no callers anywhere in the codebase — the only match forpeer_id_from_node_idis its definition. This may be intentional if an upstack PR in the stack will consume it, but as it stands in this PR, it introduces dead code along with unusedanyhowandlibp2pimports.