Skip to content

Commit

Permalink
feat: change by upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
driftluo committed Jan 15, 2025
1 parent f95b53d commit 37a52d9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions multiaddr/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const WS: u32 = 0x01dd;
const WSS: u32 = 0x01de;
const MEMORY: u32 = 0x0309;

const SHA256_CODE: u16 = 0x12;
const SHA256_CODE: u64 = 0x12;
const SHA256_SIZE: u8 = 32;

/// `Protocol` describes all possible multiaddress protocols.
Expand Down Expand Up @@ -276,7 +276,7 @@ impl<'a> From<Ipv6Addr> for Protocol<'a> {
}

fn check_p2p(data: &[u8]) -> Result<(), Error> {
let (code, bytes) = unsigned_varint::decode::u16(data)?;
let (code, bytes) = unsigned_varint::decode::u64(data)?;

if code != SHA256_CODE {
return Err(Error::UnknownHash);
Expand Down
8 changes: 4 additions & 4 deletions secio/src/peer_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use unsigned_varint::{decode, encode};

use crate::handshake::handshake_struct::PublicKey;

const SHA256_CODE: u16 = 0x12;
const SHA256_CODE: u64 = 0x12;
const SHA256_SIZE: u8 = 32;

/// Identifier of a peer of the network
Expand All @@ -31,7 +31,7 @@ impl PeerId {
return Err(Error::Empty);
}

let (code, bytes) = decode::u16(&data).map_err(|_| Error::InvalidData)?;
let (code, bytes) = decode::u64(&data).map_err(|_| Error::InvalidData)?;

if code != SHA256_CODE {
return Err(Error::NotSupportHashCode);
Expand All @@ -57,8 +57,8 @@ impl PeerId {

/// Return `PeerId` which used hashed seed as inner.
fn from_seed(seed: &[u8]) -> Self {
let mut buf = encode::u16_buffer();
let code = encode::u16(SHA256_CODE, &mut buf);
let mut buf = encode::u64_buffer();
let code = encode::u64(SHA256_CODE, &mut buf);

let header_len = code.len() + 1;

Expand Down

0 comments on commit 37a52d9

Please sign in to comment.