Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ features-check:
# required wasm32-unknown-unknown target
$(Change_Work_Path) && cargo build --features wasm-timer,unstable --no-default-features --target=wasm32-unknown-unknown
$(Change_Work_Path) && cargo build --features wasm-timer,unstable,secio-async-trait --no-default-features --target=wasm32-unknown-unknown
# required wasm32-wasip1 target
$(Change_Work_Path) && cargo build --features wasm-timer,unstable --no-default-features --target=wasm32-wasip1
$(Change_Work_Path) && cargo build --features wasm-timer,unstable,secio-async-trait --no-default-features --target=wasm32-wasip1

bench_p2p:
cd bench && cargo run --release

Expand Down
2 changes: 1 addition & 1 deletion fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ edition = "2021"
cargo-fuzz = true

[dependencies]
libfuzzer-sys = "0.3"
libfuzzer-sys = "0.4"
tentacle-secio = { path = "../secio" }
tokio-yamux = { path = "../yamux" }
rand = "0.8"
Expand Down
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
Loading