cargo +nightly fmt (#3540)

* cargo +nightly fmt

* add cargo-fmt check to ci

* update ci

* fmt

* fmt

* skip macro

* ignore bridges
This commit is contained in:
Shawn Tabrizi
2021-08-02 12:47:33 +02:00
committed by GitHub
parent 30e3012270
commit ff5d56fb76
350 changed files with 20617 additions and 21266 deletions
+22 -38
View File
@@ -14,23 +14,21 @@
// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
use std::borrow::Cow;
use std::collections::HashSet;
use std::sync::Arc;
use std::{borrow::Cow, collections::HashSet, sync::Arc};
use async_trait::async_trait;
use futures::prelude::*;
use futures::stream::BoxStream;
use futures::{prelude::*, stream::BoxStream};
use parity_scale_codec::Encode;
use sc_network::Event as NetworkEvent;
use sc_network::{IfDisconnected, NetworkService, OutboundFailure, RequestFailure};
use sc_network::{config::parse_addr, multiaddr::Multiaddr};
use sc_network::{
config::parse_addr, multiaddr::Multiaddr, Event as NetworkEvent, IfDisconnected,
NetworkService, OutboundFailure, RequestFailure,
};
use polkadot_node_network_protocol::{
peer_set::PeerSet,
request_response::{OutgoingRequest, Requests, Recipient},
request_response::{OutgoingRequest, Recipient, Requests},
PeerId, UnifiedReputationChange as Rep,
};
use polkadot_primitives::v1::{AuthorityDiscoveryId, Block, Hash};
@@ -50,8 +48,7 @@ pub(crate) fn send_message<M>(
peer_set: PeerSet,
message: M,
metrics: &super::Metrics,
)
where
) where
M: Encode + Clone,
{
let message = {
@@ -112,12 +109,7 @@ pub trait Network: Clone + Send + 'static {
fn disconnect_peer(&self, who: PeerId, peer_set: PeerSet);
/// Write a notification to a peer on the given peer-set's protocol.
fn write_notification(
&self,
who: PeerId,
peer_set: PeerSet,
message: Vec<u8>,
);
fn write_notification(&self, who: PeerId, peer_set: PeerSet, message: Vec<u8>);
}
#[async_trait]
@@ -170,38 +162,29 @@ impl Network for Arc<NetworkService<Block, Hash>> {
req: Requests,
if_disconnected: IfDisconnected,
) {
let (
protocol,
OutgoingRequest {
peer,
payload,
pending_response,
},
) = req.encode_request();
let (protocol, OutgoingRequest { peer, payload, pending_response }) = req.encode_request();
let peer_id = match peer {
Recipient::Peer(peer_id) => Some(peer_id),
Recipient::Peer(peer_id) => Some(peer_id),
Recipient::Authority(authority) => {
let mut found_peer_id = None;
// Note: `get_addresses_by_authority_id` searched in a cache, and it thus expected
// to be very quick.
for addr in authority_discovery
.get_addresses_by_authority_id(authority).await
.into_iter().flat_map(|list| list.into_iter())
.get_addresses_by_authority_id(authority)
.await
.into_iter()
.flat_map(|list| list.into_iter())
{
let (peer_id, addr) = match parse_addr(addr) {
Ok(v) => v,
Err(_) => continue,
};
NetworkService::add_known_address(
&*self,
peer_id.clone(),
addr,
);
NetworkService::add_known_address(&*self, peer_id.clone(), addr);
found_peer_id = Some(peer_id);
}
found_peer_id
}
},
};
let peer_id = match peer_id {
@@ -214,10 +197,10 @@ impl Network for Arc<NetworkService<Block, Hash>> {
target: LOG_TARGET,
"Sending failed request response failed."
),
Ok(_) => {}
Ok(_) => {},
}
return;
}
return
},
Some(peer_id) => peer_id,
};
@@ -240,7 +223,8 @@ pub async fn get_peer_id_by_authority_id<AD: AuthorityDiscovery>(
// Note: `get_addresses_by_authority_id` searched in a cache, and it thus expected
// to be very quick.
authority_discovery
.get_addresses_by_authority_id(authority).await
.get_addresses_by_authority_id(authority)
.await
.into_iter()
.flat_map(|list| list.into_iter())
.find_map(|addr| parse_addr(addr).ok().map(|(p, _)| p))