mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-07-03 19:51:33 +00:00
feat(swarm)!: introduce ListenError
(#3375)
In case an error happens for an outgoing connection, `Pool` reports an `OutgoingConnectionError`. This one is mapped to a `DialError` and reported via `SwarmEvent::OutgoingConnectionError` and `FromSwarm::DialFailure`. For incoming connections, we didn't quite do the same thing. For one, `SwarmEvent::IncomingConnectionError` directly contained a `PendingInboundConnectionError`. Two, `FromSwarm::ListenFailure` did not include an error at all. With this patch, we now introduce a `ListenError` enum which we use in `SwarmEvent::IncomingConnectionError` and we pass a reference to it along in `FromSwarm::ListenFailure`.
This commit is contained in:
@ -344,6 +344,7 @@ fn build_struct(ast: &DeriveInput, data_struct: &DataStruct) -> TokenStream {
|
||||
self.#i.on_swarm_event(#from_swarm::ListenFailure(#listen_failure {
|
||||
local_addr,
|
||||
send_back_addr,
|
||||
error,
|
||||
handler,
|
||||
}));
|
||||
},
|
||||
@ -351,6 +352,7 @@ fn build_struct(ast: &DeriveInput, data_struct: &DataStruct) -> TokenStream {
|
||||
self.#enum_n.on_swarm_event(#from_swarm::ListenFailure(#listen_failure {
|
||||
local_addr,
|
||||
send_back_addr,
|
||||
error,
|
||||
handler,
|
||||
}));
|
||||
},
|
||||
@ -747,7 +749,7 @@ fn build_struct(ast: &DeriveInput, data_struct: &DataStruct) -> TokenStream {
|
||||
#dial_failure { peer_id, handler: handlers, error })
|
||||
=> { #(#on_dial_failure_stmts)* }
|
||||
#from_swarm::ListenFailure(
|
||||
#listen_failure { local_addr, send_back_addr, handler: handlers })
|
||||
#listen_failure { local_addr, send_back_addr, handler: handlers, error })
|
||||
=> { #(#on_listen_failure_stmts)* }
|
||||
#from_swarm::NewListener(
|
||||
#new_listener { listener_id })
|
||||
|
Reference in New Issue
Block a user