mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-16 11:31:22 +00:00
Chore/semi colons (#799)
* Add helpers for easier Transports creation (#777) * Add helpers for easier Transports creation * Fix doctests * Fix ' ;' occurrences
This commit is contained in:
committed by
Toralf Wittner
parent
83320e0347
commit
f541df391a
@ -54,7 +54,7 @@ pub fn build_query() -> Vec<u8> {
|
|||||||
// Program-generated transaction ID; unused by our implementation.
|
// Program-generated transaction ID; unused by our implementation.
|
||||||
append_u16(&mut out, rand::random());
|
append_u16(&mut out, rand::random());
|
||||||
|
|
||||||
// Flags ; 0x0 for a regular query.
|
// 0x0 flag for a regular query.
|
||||||
append_u16(&mut out, 0x0);
|
append_u16(&mut out, 0x0);
|
||||||
|
|
||||||
// Number of questions.
|
// Number of questions.
|
||||||
@ -98,7 +98,7 @@ pub fn build_query_response(
|
|||||||
let mut out = Vec::with_capacity(320);
|
let mut out = Vec::with_capacity(320);
|
||||||
|
|
||||||
append_u16(&mut out, id);
|
append_u16(&mut out, id);
|
||||||
// Flags ; 0x84 for an answer.
|
// 0x84 flag for an answer.
|
||||||
append_u16(&mut out, 0x8400);
|
append_u16(&mut out, 0x8400);
|
||||||
// Number of questions, answers, authorities, additionals.
|
// Number of questions, answers, authorities, additionals.
|
||||||
append_u16(&mut out, 0x0);
|
append_u16(&mut out, 0x0);
|
||||||
@ -156,7 +156,7 @@ pub fn build_service_discovery_response(id: u16, ttl: Duration) -> Vec<u8> {
|
|||||||
let mut out = Vec::with_capacity(69);
|
let mut out = Vec::with_capacity(69);
|
||||||
|
|
||||||
append_u16(&mut out, id);
|
append_u16(&mut out, id);
|
||||||
// Flags ; 0x84 for an answer.
|
// 0x84 flag for an answer.
|
||||||
append_u16(&mut out, 0x8400);
|
append_u16(&mut out, 0x8400);
|
||||||
// Number of questions, answers, authorities, additionals.
|
// Number of questions, answers, authorities, additionals.
|
||||||
append_u16(&mut out, 0x0);
|
append_u16(&mut out, 0x0);
|
||||||
|
@ -175,7 +175,7 @@ impl MdnsService {
|
|||||||
/// Polls the service for packets.
|
/// Polls the service for packets.
|
||||||
pub fn poll(&mut self) -> Async<MdnsPacket> {
|
pub fn poll(&mut self) -> Async<MdnsPacket> {
|
||||||
// Send a query every time `query_interval` fires.
|
// Send a query every time `query_interval` fires.
|
||||||
// Note that we don't use a loop here ; it is pretty unlikely that we need it, and there is
|
// Note that we don't use a loop here—it is pretty unlikely that we need it, and there is
|
||||||
// no point in sending multiple requests in a row.
|
// no point in sending multiple requests in a row.
|
||||||
match self.query_interval.poll() {
|
match self.query_interval.poll() {
|
||||||
Ok(Async::Ready(_)) => {
|
Ok(Async::Ready(_)) => {
|
||||||
@ -472,7 +472,7 @@ impl<'a> fmt::Debug for MdnsResponse<'a> {
|
|||||||
|
|
||||||
/// A peer discovered by the service.
|
/// A peer discovered by the service.
|
||||||
pub struct MdnsPeer<'a> {
|
pub struct MdnsPeer<'a> {
|
||||||
/// The original packet ; will be used to determine the addresses.
|
/// The original packet which will be used to determine the addresses.
|
||||||
packet: &'a Packet<'a>,
|
packet: &'a Packet<'a>,
|
||||||
/// Cached value of `concat(base32(peer_id), service name)`.
|
/// Cached value of `concat(base32(peer_id), service name)`.
|
||||||
record_value: String,
|
record_value: String,
|
||||||
|
@ -184,9 +184,9 @@ where TMuxer: muxing::StreamMuxer + Send + Sync + 'static,
|
|||||||
// Here is a tricky part: we need to get back the muxer in order to return
|
// Here is a tricky part: we need to get back the muxer in order to return
|
||||||
// it, but it is in an `Arc`.
|
// it, but it is in an `Arc`.
|
||||||
let unwrapped = Arc::try_unwrap(muxer).unwrap_or_else(|_| {
|
let unwrapped = Arc::try_unwrap(muxer).unwrap_or_else(|_| {
|
||||||
panic!("we clone the Arc only to put it into substreams ; once in the \
|
panic!("We clone the Arc only to put it into substreams. Once in the \
|
||||||
Finishing state, no substream or upgrade exists anymore ; \
|
Finishing state, no substream or upgrade exists anymore. \
|
||||||
therefore there exists only one instance of the Arc; QED")
|
Therefore, there exists only one instance of the Arc. QED")
|
||||||
});
|
});
|
||||||
|
|
||||||
// We leave `Poisoned` as the state when returning.
|
// We leave `Poisoned` as the state when returning.
|
||||||
|
@ -107,7 +107,7 @@ where
|
|||||||
}
|
}
|
||||||
EitherOutput::First(sender) => {
|
EitherOutput::First(sender) => {
|
||||||
let observed = self.observed_addresses.get(&peer_id)
|
let observed = self.observed_addresses.get(&peer_id)
|
||||||
.expect("We only receive events from nodes we're connected to ; we insert \
|
.expect("We only receive events from nodes we're connected to. We insert \
|
||||||
into the hashmap when we connect to a node and remove only when we \
|
into the hashmap when we connect to a node and remove only when we \
|
||||||
disconnect; QED");
|
disconnect; QED");
|
||||||
self.to_answer.push((sender, observed.clone()));
|
self.to_answer.push((sender, observed.clone()));
|
||||||
|
@ -479,7 +479,7 @@ where
|
|||||||
let (query, purpose, provider_peers) = self
|
let (query, purpose, provider_peers) = self
|
||||||
.active_queries
|
.active_queries
|
||||||
.remove(&finished_query)
|
.remove(&finished_query)
|
||||||
.expect("finished_query was gathered when iterating active_queries ; qed");
|
.expect("finished_query was gathered when iterating active_queries; QED.");
|
||||||
match purpose {
|
match purpose {
|
||||||
QueryPurpose::Initialization => {},
|
QueryPurpose::Initialization => {},
|
||||||
QueryPurpose::UserRequest => {
|
QueryPurpose::UserRequest => {
|
||||||
|
@ -745,8 +745,8 @@ fn process_kad_request<TUserData>(
|
|||||||
) -> Result<KademliaHandlerEvent<TUserData>, io::Error> {
|
) -> Result<KademliaHandlerEvent<TUserData>, io::Error> {
|
||||||
match event {
|
match event {
|
||||||
KadRequestMsg::Ping => {
|
KadRequestMsg::Ping => {
|
||||||
// TODO: implement ; in practice the PING message is never used, so we may consider
|
// TODO: implement; although in practice the PING message is never
|
||||||
// removing it altogether
|
// used, so we may consider removing it altogether
|
||||||
Err(io::Error::new(
|
Err(io::Error::new(
|
||||||
io::ErrorKind::InvalidData,
|
io::ErrorKind::InvalidData,
|
||||||
"the PING Kademlia message is not implemented",
|
"the PING Kademlia message is not implemented",
|
||||||
|
@ -92,8 +92,8 @@ enum QueryStage {
|
|||||||
Iterating {
|
Iterating {
|
||||||
/// Number of successful query results in a row that didn't find any closer node.
|
/// Number of successful query results in a row that didn't find any closer node.
|
||||||
// TODO: this is not great, because we don't necessarily receive responses in the order
|
// TODO: this is not great, because we don't necessarily receive responses in the order
|
||||||
// we made the queries ; it is possible that we query multiple far-away nodes in a
|
// we made the queries. It is possible that we query multiple far-away nodes in a
|
||||||
// row, and obtain results before the result of the closest nodes
|
// row, and obtain results before the result of the closest nodes.
|
||||||
no_closer_in_a_row: usize,
|
no_closer_in_a_row: usize,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user