mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-26 00:01:33 +00:00
Use stronger typing for the public key of identify (#236)
* Use stronger typing for the public key of identify * Add PartialEq/Eq implementations * Fix tests * Also change is_public_key()
This commit is contained in:
@ -31,7 +31,7 @@ use futures::Stream;
|
||||
use futures::future::Future;
|
||||
use std::{env, mem};
|
||||
use libp2p::core::{either::EitherOutput, upgrade};
|
||||
use libp2p::core::{Multiaddr, Transport};
|
||||
use libp2p::core::{Multiaddr, Transport, PublicKeyBytesSlice};
|
||||
use libp2p::peerstore::PeerId;
|
||||
use libp2p::tcp::TcpConfig;
|
||||
use tokio_core::reactor::Core;
|
||||
@ -91,7 +91,7 @@ fn main() {
|
||||
// or substream to our server.
|
||||
let my_id = {
|
||||
let key = (0..2048).map(|_| rand::random::<u8>()).collect::<Vec<_>>();
|
||||
PeerId::from_public_key(&key)
|
||||
PeerId::from_public_key(PublicKeyBytesSlice(&key))
|
||||
};
|
||||
|
||||
let (floodsub_upgrade, floodsub_rx) = libp2p::floodsub::FloodSubUpgrade::new(my_id);
|
||||
|
@ -33,7 +33,7 @@ use libp2p::Multiaddr;
|
||||
use std::env;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
use libp2p::core::Transport;
|
||||
use libp2p::core::{Transport, PublicKeyBytesSlice};
|
||||
use libp2p::core::{upgrade, either::EitherOutput};
|
||||
use libp2p::tcp::TcpConfig;
|
||||
use tokio_core::reactor::Core;
|
||||
@ -96,7 +96,7 @@ fn main() {
|
||||
// incoming connections, and that will automatically apply secio and multiplex on top
|
||||
// of any opened stream.
|
||||
|
||||
let my_peer_id = PeerId::from_public_key(include_bytes!("test-rsa-public-key.der"));
|
||||
let my_peer_id = PeerId::from_public_key(PublicKeyBytesSlice(include_bytes!("test-rsa-public-key.der")));
|
||||
println!("Local peer id is: {:?}", my_peer_id);
|
||||
|
||||
// Let's put this `transport` into a Kademlia *swarm*. The swarm will handle all the incoming
|
||||
|
@ -21,12 +21,12 @@
|
||||
extern crate libp2p;
|
||||
extern crate rand;
|
||||
|
||||
use libp2p::PeerId;
|
||||
use libp2p::{PeerId, core::PublicKeyBytesSlice};
|
||||
|
||||
fn main() {
|
||||
let pid = {
|
||||
let key = (0..2048).map(|_| rand::random::<u8>()).collect::<Vec<_>>();
|
||||
PeerId::from_public_key(&key)
|
||||
PeerId::from_public_key(PublicKeyBytesSlice(&key))
|
||||
};
|
||||
println!("{}", pid.to_base58());
|
||||
}
|
||||
|
Reference in New Issue
Block a user