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:
Thomas Eizinger
2023-03-13 01:46:58 +11:00
committed by GitHub
parent d81f9476f7
commit 2a14df25eb
180 changed files with 1014 additions and 347 deletions

View File

@ -34,7 +34,8 @@ use crate::{
AddressRecord, AddressScore, ConnectionDenied, DialError, ListenError, THandler,
THandlerInEvent, THandlerOutEvent,
};
use libp2p_core::{transport::ListenerId, ConnectedPoint, Endpoint, Multiaddr, PeerId};
use libp2p_core::{transport::ListenerId, ConnectedPoint, Endpoint, Multiaddr};
use libp2p_identity::PeerId;
use std::{task::Context, task::Poll};
/// A [`NetworkBehaviour`] defines the behaviour of the local node on the network.

View File

@ -22,7 +22,8 @@ use crate::behaviour::{self, NetworkBehaviour, NetworkBehaviourAction, PollParam
use crate::connection::ConnectionId;
use crate::{ConnectionDenied, THandler, THandlerInEvent, THandlerOutEvent};
use either::Either;
use libp2p_core::{Endpoint, Multiaddr, PeerId};
use libp2p_core::{Endpoint, Multiaddr};
use libp2p_identity::PeerId;
use std::{task::Context, task::Poll};
/// Implementation of [`NetworkBehaviour`] that can be either of two implementations.

View File

@ -32,7 +32,8 @@ use crate::{
};
use either::Either;
use futures::future;
use libp2p_core::{upgrade::DeniedUpgrade, Endpoint, Multiaddr, PeerId};
use libp2p_core::{upgrade::DeniedUpgrade, Endpoint, Multiaddr};
use libp2p_identity::PeerId;
use std::{task::Context, task::Poll};
/// Implementation of `NetworkBehaviour` that can be either in the disabled or enabled state.

View File

@ -42,8 +42,9 @@ use libp2p_core::connection::ConnectedPoint;
use libp2p_core::multiaddr::Multiaddr;
use libp2p_core::muxing::{StreamMuxerBox, StreamMuxerEvent, StreamMuxerExt, SubstreamBox};
use libp2p_core::upgrade::{InboundUpgradeApply, OutboundUpgradeApply};
use libp2p_core::Endpoint;
use libp2p_core::{upgrade, UpgradeError};
use libp2p_core::{Endpoint, PeerId};
use libp2p_identity::PeerId;
use std::future::Future;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::task::Waker;

View File

@ -25,7 +25,7 @@ use futures::{
stream::{FuturesUnordered, StreamExt},
};
use libp2p_core::muxing::StreamMuxerBox;
use libp2p_core::PeerId;
use libp2p_identity::PeerId;
use std::{
num::NonZeroU8,
pin::Pin,

View File

@ -23,7 +23,8 @@ use crate::ConnectionId;
use libp2p_core::connection::Endpoint;
use libp2p_core::multiaddr::Protocol;
use libp2p_core::multihash::Multihash;
use libp2p_core::{Multiaddr, PeerId};
use libp2p_core::Multiaddr;
use libp2p_identity::PeerId;
use std::num::NonZeroU8;
/// Options to configure a dial to a known or unknown peer.
@ -52,7 +53,7 @@ impl DialOpts {
///
/// ```
/// # use libp2p_swarm::dial_opts::{DialOpts, PeerCondition};
/// # use libp2p_core::PeerId;
/// # use libp2p_identity::PeerId;
/// DialOpts::peer_id(PeerId::random())
/// .condition(PeerCondition::Disconnected)
/// .addresses(vec!["/ip6/::1/tcp/12345".parse().unwrap()])
@ -327,7 +328,7 @@ impl WithoutPeerIdWithAddress {
///
/// ```
/// # use libp2p_swarm::dial_opts::{DialOpts, PeerCondition};
/// # use libp2p_core::PeerId;
/// # use libp2p_identity::PeerId;
/// #
/// DialOpts::peer_id(PeerId::random())
/// .condition(PeerCondition::Disconnected)

View File

@ -8,8 +8,9 @@ use crate::{
SubstreamProtocol, THandler, THandlerInEvent, THandlerOutEvent,
};
use libp2p_core::upgrade::DeniedUpgrade;
use libp2p_core::{Endpoint, PeerId};
use libp2p_core::Endpoint;
use libp2p_core::{Multiaddr, UpgradeError};
use libp2p_identity::PeerId;
use std::task::{Context, Poll};
use void::Void;

View File

@ -49,7 +49,8 @@ mod select;
pub use crate::upgrade::{InboundUpgradeSend, OutboundUpgradeSend, SendWrapper, UpgradeInfoSend};
use instant::Instant;
use libp2p_core::{upgrade::UpgradeError, ConnectedPoint, Multiaddr, PeerId};
use libp2p_core::{upgrade::UpgradeError, ConnectedPoint, Multiaddr};
use libp2p_identity::PeerId;
use std::{cmp::Ordering, error, fmt, task::Context, task::Poll, time::Duration};
pub use map_in::MapInEvent;

View File

@ -28,7 +28,8 @@ use crate::upgrade::SendWrapper;
use crate::ConnectionHandlerUpgrErr;
use either::Either;
use futures::future;
use libp2p_core::{ConnectedPoint, PeerId, UpgradeError};
use libp2p_core::{ConnectedPoint, UpgradeError};
use libp2p_identity::PeerId;
use std::task::{Context, Poll};
/// Auxiliary type to allow implementing [`IntoConnectionHandler`]. As [`IntoConnectionHandler`] is

View File

@ -32,7 +32,8 @@ use crate::upgrade::{InboundUpgradeSend, OutboundUpgradeSend, UpgradeInfoSend};
use crate::NegotiatedSubstream;
use futures::{future::BoxFuture, prelude::*};
use libp2p_core::upgrade::{NegotiationError, ProtocolError, ProtocolName, UpgradeError};
use libp2p_core::{ConnectedPoint, PeerId};
use libp2p_core::ConnectedPoint;
use libp2p_identity::PeerId;
use rand::Rng;
use std::{
cmp,

View File

@ -30,8 +30,9 @@ use either::Either;
use futures::future;
use libp2p_core::{
upgrade::{NegotiationError, ProtocolError, SelectUpgrade, UpgradeError},
ConnectedPoint, PeerId,
ConnectedPoint,
};
use libp2p_identity::PeerId;
use std::{cmp, task::Context, task::Poll};
/// Implementation of `IntoConnectionHandler` that combines two protocols into one.

View File

@ -6,7 +6,8 @@ use crate::handler::{
};
use crate::{ConnectionDenied, THandler, THandlerInEvent, THandlerOutEvent};
use libp2p_core::upgrade::DeniedUpgrade;
use libp2p_core::{Endpoint, Multiaddr, PeerId};
use libp2p_core::{Endpoint, Multiaddr};
use libp2p_identity::PeerId;
use std::task::{Context, Poll};
use void::Void;

View File

@ -101,7 +101,7 @@ pub mod derive_prelude {
pub use libp2p_core::ConnectedPoint;
pub use libp2p_core::Endpoint;
pub use libp2p_core::Multiaddr;
pub use libp2p_core::PeerId;
pub use libp2p_identity::PeerId;
}
pub use behaviour::{
@ -139,8 +139,9 @@ use libp2p_core::{
multihash::Multihash,
muxing::StreamMuxerBox,
transport::{self, ListenerId, TransportError, TransportEvent},
Endpoint, Multiaddr, Negotiated, PeerId, ProtocolName, Transport,
Endpoint, Multiaddr, Negotiated, ProtocolName, Transport,
};
use libp2p_identity::PeerId;
use registry::{AddressIntoIter, Addresses};
use smallvec::SmallVec;
use std::collections::{HashMap, HashSet};
@ -1955,8 +1956,9 @@ mod tests {
use libp2p_core::multiaddr::multiaddr;
use libp2p_core::transport::memory::MemoryTransportError;
use libp2p_core::transport::TransportEvent;
use libp2p_core::{identity, multiaddr, transport, upgrade};
use libp2p_core::{multiaddr, transport, upgrade};
use libp2p_core::{Endpoint, UpgradeError};
use libp2p_identity as identity;
use libp2p_plaintext as plaintext;
use libp2p_yamux as yamux;
use quickcheck::*;

View File

@ -26,7 +26,8 @@ use crate::{
ConnectionDenied, ConnectionHandler, ConnectionId, NetworkBehaviour, NetworkBehaviourAction,
PollParameters, THandler, THandlerInEvent, THandlerOutEvent,
};
use libp2p_core::{multiaddr::Multiaddr, transport::ListenerId, ConnectedPoint, Endpoint, PeerId};
use libp2p_core::{multiaddr::Multiaddr, transport::ListenerId, ConnectedPoint, Endpoint};
use libp2p_identity::PeerId;
use std::collections::HashMap;
use std::task::{Context, Poll};