mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-14 02:21:21 +00:00
Split address reach error and node reach error (#1013)
* Split address reach error and node reach error * Small comments about order of operatoins * Minor doc change
This commit is contained in:
@ -214,6 +214,20 @@ fn build_struct(ast: &DeriveInput, data_struct: &DataStruct) -> TokenStream {
|
||||
})
|
||||
};
|
||||
|
||||
// Build the list of statements to put in the body of `inject_addr_reach_failure()`.
|
||||
let inject_addr_reach_failure_stmts = {
|
||||
data_struct.fields.iter().enumerate().filter_map(move |(field_n, field)| {
|
||||
if is_ignored(&field) {
|
||||
return None;
|
||||
}
|
||||
|
||||
Some(match field.ident {
|
||||
Some(ref i) => quote!{ self.#i.inject_addr_reach_failure(peer_id, addr, error); },
|
||||
None => quote!{ self.#field_n.inject_addr_reach_failure(peer_id, addr, error); },
|
||||
})
|
||||
})
|
||||
};
|
||||
|
||||
// Build the list of statements to put in the body of `inject_dial_failure()`.
|
||||
let inject_dial_failure_stmts = {
|
||||
data_struct.fields.iter().enumerate().filter_map(move |(field_n, field)| {
|
||||
@ -222,8 +236,8 @@ fn build_struct(ast: &DeriveInput, data_struct: &DataStruct) -> TokenStream {
|
||||
}
|
||||
|
||||
Some(match field.ident {
|
||||
Some(ref i) => quote!{ self.#i.inject_dial_failure(peer_id, addr, error); },
|
||||
None => quote!{ self.#field_n.inject_dial_failure(peer_id, addr, error); },
|
||||
Some(ref i) => quote!{ self.#i.inject_dial_failure(peer_id); },
|
||||
None => quote!{ self.#field_n.inject_dial_failure(peer_id); },
|
||||
})
|
||||
})
|
||||
};
|
||||
@ -396,7 +410,12 @@ fn build_struct(ast: &DeriveInput, data_struct: &DataStruct) -> TokenStream {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn inject_dial_failure(&mut self, peer_id: Option<&#peer_id>, addr: &#multiaddr, error: &dyn std::error::Error) {
|
||||
fn inject_addr_reach_failure(&mut self, peer_id: Option<&#peer_id>, addr: &#multiaddr, error: &dyn std::error::Error) {
|
||||
#(#inject_addr_reach_failure_stmts);*
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn inject_dial_failure(&mut self, peer_id: &#peer_id) {
|
||||
#(#inject_dial_failure_stmts);*
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user