mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-22 14:21:33 +00:00
feat: introduce libp2p-identity
crate
This patch combines the `libp2p_core::identity` and `libp2p_core::peer_id` modules into a new crate: `libp2p-identity`. Resolves https://github.com/libp2p/rust-libp2p/issues/3349. Pull-Request: #3350.
This commit is contained in:
@ -81,10 +81,7 @@ use clap::Parser;
|
||||
|
||||
use futures::prelude::*;
|
||||
use futures::StreamExt;
|
||||
use libp2p::{
|
||||
core::{Multiaddr, PeerId},
|
||||
multiaddr::Protocol,
|
||||
};
|
||||
use libp2p::{core::Multiaddr, multiaddr::Protocol, PeerId};
|
||||
use std::error::Error;
|
||||
use std::io::Write;
|
||||
use std::path::PathBuf;
|
||||
|
@ -7,7 +7,7 @@ use futures::prelude::*;
|
||||
use libp2p::{
|
||||
core::{
|
||||
upgrade::{read_length_prefixed, write_length_prefixed, ProtocolName},
|
||||
Multiaddr, PeerId,
|
||||
Multiaddr,
|
||||
},
|
||||
identity,
|
||||
kad::{
|
||||
@ -16,6 +16,7 @@ use libp2p::{
|
||||
multiaddr::Protocol,
|
||||
request_response::{self, ProtocolSupport, RequestId, ResponseChannel},
|
||||
swarm::{ConnectionHandlerUpgrErr, NetworkBehaviour, Swarm, SwarmEvent},
|
||||
PeerId,
|
||||
};
|
||||
|
||||
use std::collections::{hash_map, HashMap, HashSet};
|
||||
@ -38,10 +39,7 @@ pub async fn new(
|
||||
Some(seed) => {
|
||||
let mut bytes = [0u8; 32];
|
||||
bytes[0] = seed;
|
||||
let secret_key = identity::ed25519::SecretKey::from_bytes(&mut bytes).expect(
|
||||
"this returns `Err` only if the length is wrong; the length is correct; qed",
|
||||
);
|
||||
identity::Keypair::Ed25519(secret_key.into())
|
||||
identity::Keypair::ed25519_from_bytes(bytes).unwrap()
|
||||
}
|
||||
None => identity::Keypair::generate_ed25519(),
|
||||
};
|
||||
|
Reference in New Issue
Block a user