more libp2p updating
This commit is contained in:
parent
c3a48c9699
commit
4e5ff4d23e
@ -743,7 +743,7 @@ impl<Types: IpfsTypes> Ipfs<Types> {
|
||||
.await?;
|
||||
let mut addresses = rx.await?;
|
||||
let public_key = self.keys.get_ref().public();
|
||||
let peer_id = public_key.clone().into_peer_id();
|
||||
let peer_id = public_key.clone().to_peer_id();
|
||||
|
||||
for addr in &mut addresses {
|
||||
addr.push(Protocol::P2p(peer_id.into()))
|
||||
@ -1689,7 +1689,7 @@ mod node {
|
||||
|
||||
/// Returns a new `Node` based on `IpfsOptions`.
|
||||
pub async fn with_options(opts: IpfsOptions) -> Self {
|
||||
let id = opts.keypair.public().into_peer_id();
|
||||
let id = opts.keypair.public().to_peer_id();
|
||||
|
||||
// for future: assume UninitializedIpfs handles instrumenting any futures with the
|
||||
// given span
|
||||
|
@ -22,6 +22,7 @@ use tokio::task;
|
||||
|
||||
/// Behaviour type.
|
||||
#[derive(libp2p::NetworkBehaviour)]
|
||||
#[behaviour(out_event = "BehaviourEvent")]
|
||||
pub struct Behaviour<Types: IpfsTypes> {
|
||||
#[behaviour(ignore)]
|
||||
repo: Arc<Repo<Types>>,
|
||||
@ -36,6 +37,45 @@ pub struct Behaviour<Types: IpfsTypes> {
|
||||
pub swarm: SwarmApi,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum BehaviourEvent {
|
||||
Kademlia(KademliaEvent),
|
||||
Ping(PingEvent),
|
||||
Identify(IdentifyEvent),
|
||||
Bitswap(BitswapEvent),
|
||||
Void,
|
||||
}
|
||||
|
||||
impl From<KademliaEvent> for BehaviourEvent {
|
||||
fn from(event: KademliaEvent) -> Self {
|
||||
Self::Kademlia(event)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<PingEvent> for BehaviourEvent {
|
||||
fn from(event: PingEvent) -> Self {
|
||||
Self::Ping(event)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<IdentifyEvent> for BehaviourEvent {
|
||||
fn from(event: IdentifyEvent) -> Self {
|
||||
Self::Identify(event)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<BitswapEvent> for BehaviourEvent {
|
||||
fn from(event: BitswapEvent) -> Self {
|
||||
Self::Bitswap(event)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<void::Void> for BehaviourEvent {
|
||||
fn from(_void: void::Void) -> Self {
|
||||
Self::Void
|
||||
}
|
||||
}
|
||||
|
||||
/// Represents the result of a Kademlia query.
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum KadResult {
|
||||
|
@ -233,8 +233,8 @@ impl Pubsub {
|
||||
}
|
||||
|
||||
type PubsubNetworkBehaviourAction = NetworkBehaviourAction<
|
||||
<<Pubsub as NetworkBehaviour>::ConnectionHandler as ConnectionHandler>::InEvent,
|
||||
<Pubsub as NetworkBehaviour>::OutEvent,
|
||||
<<Pubsub as NetworkBehaviour>::ConnectionHandler as ConnectionHandler>::OutEvent,
|
||||
<Pubsub as NetworkBehaviour>::ConnectionHandler,
|
||||
>;
|
||||
|
||||
impl NetworkBehaviour for Pubsub {
|
||||
|
@ -36,8 +36,8 @@ impl Disconnector {
|
||||
|
||||
// Currently this is swarm::NetworkBehaviourAction<Void, Void>
|
||||
type NetworkBehaviourAction = swarm::NetworkBehaviourAction<
|
||||
<<SwarmApi as NetworkBehaviour>::ConnectionHandler as ConnectionHandler>::InEvent,
|
||||
<<SwarmApi as NetworkBehaviour>::ConnectionHandler as ConnectionHandler>::OutEvent,
|
||||
<SwarmApi as NetworkBehaviour>::ConnectionHandler,
|
||||
>;
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
|
Loading…
x
Reference in New Issue
Block a user