When want to know current network state, need a function to get.
How
Add SendMessage::NetworkState
enum SendMessage {
...
/// Request for return the network current state info.
/// params is request type, and return channel's sender (async).
NetworkState(StateRequest, Sender<StateResponse>),
}
/// Network state info response.
#[derive(Debug, Clone)]
pub enum StateRequest {
Stable,
DHT,
Seed,
}
/// Network state info response.
#[derive(Debug, Clone)]
pub enum StateResponse {
/// response is peer list and peer is relay or directly.
Stable(Vec<(PeerId, bool)>),
/// response is peer list.
DHT(Vec<PeerId>),
/// response is socket list.
Seed(Vec<SocketAddr>),
}
Why
When want to know current network state, need a function to get.
How
SendMessage::NetworkState