mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-12 01:21:21 +00:00
Enhance the swarm a bit (#711)
* Replace the &mut TTopology with a &mut PollParameters * Add supported_protocols * Add external_addresses * Report out addresses in Kademlia * Fix the custom derive * Some comments * Fix compilation on stable
This commit is contained in:
@ -79,6 +79,8 @@ fn build_struct(ast: &DeriveInput, data_struct: &DataStruct) -> TokenStream {
|
||||
quote!{#n}
|
||||
};
|
||||
|
||||
let poll_parameters = quote!{::libp2p::core::swarm::PollParameters<#topology_generic>};
|
||||
|
||||
// Build the generics.
|
||||
let impl_generics = {
|
||||
let tp = ast.generics.type_params();
|
||||
@ -306,7 +308,7 @@ fn build_struct(ast: &DeriveInput, data_struct: &DataStruct) -> TokenStream {
|
||||
|
||||
Some(quote!{
|
||||
loop {
|
||||
match #field_name.poll(topology) {
|
||||
match #field_name.poll(poll_params) {
|
||||
Async::Ready(#network_behaviour_action::GenerateEvent(event)) => {
|
||||
#handling
|
||||
}
|
||||
@ -322,6 +324,9 @@ fn build_struct(ast: &DeriveInput, data_struct: &DataStruct) -> TokenStream {
|
||||
event: #wrapped_event,
|
||||
});
|
||||
}
|
||||
Async::Ready(#network_behaviour_action::ReportObservedAddr { address }) => {
|
||||
return Async::Ready(#network_behaviour_action::ReportObservedAddr { address });
|
||||
}
|
||||
Async::NotReady => break,
|
||||
}
|
||||
}
|
||||
@ -363,7 +368,7 @@ fn build_struct(ast: &DeriveInput, data_struct: &DataStruct) -> TokenStream {
|
||||
}
|
||||
}
|
||||
|
||||
fn poll(&mut self, topology: &mut #topology_generic) -> ::libp2p::futures::Async<#network_behaviour_action<<Self::ProtocolsHandler as #protocols_handler>::InEvent, Self::OutEvent>> {
|
||||
fn poll(&mut self, poll_params: &mut #poll_parameters) -> ::libp2p::futures::Async<#network_behaviour_action<<Self::ProtocolsHandler as #protocols_handler>::InEvent, Self::OutEvent>> {
|
||||
use libp2p::futures::prelude::*;
|
||||
#(#poll_stmts)*
|
||||
let f: ::libp2p::futures::Async<#network_behaviour_action<<Self::ProtocolsHandler as #protocols_handler>::InEvent, Self::OutEvent>> = #poll_method;
|
||||
|
Reference in New Issue
Block a user