Skip to content

Commit

Permalink
fix: use byte slice instead of vector for node id
Browse files Browse the repository at this point in the history
Co-authored-by: Guillaume Boutry <boutryguillaume1@gmail.com>
  • Loading branch information
Nuttymoon and gboutry authored Jan 11, 2023
1 parent 9388073 commit 2d93c8a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl AshNode {
Ok(AshNode { id })
}

// Create a new Ash node from an Avalanche node ID byte array
// Create a new Ash node from an Avalanche node ID byte slice
pub fn from_bytes_id(nodeid: &[u8]) -> Result<Self, Error> {
let id = Id::from_slice(nodeid);

Expand All @@ -37,15 +37,15 @@ impl AshNode {
self.id.short_id().to_string()
}

// Get the node's ID as a byte array
pub fn get_id_bytes(&self) -> Vec<u8> {
self.id.to_vec()
// Get the node's ID as a byte slice
pub fn get_id_bytes(&self) -> &[u8] {
self.id.as_ref()
}

// Get the node's ID as a hex string
pub fn get_id_hex(&self) -> String {
self.id
.to_vec()
.as_ref()
.iter()
.map(|b| format!("{:02x}", b))
.collect()
Expand Down

0 comments on commit 2d93c8a

Please sign in to comment.