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
@@ -32,19 +32,19 @@
//!
//! Versioned (v1 module): The actual requests and responses as sent over the network.
use std::{borrow::Cow, u64};
use std::time::Duration;
use std::{borrow::Cow, time::Duration, u64};
use futures::channel::mpsc;
use polkadot_primitives::v1::{MAX_CODE_SIZE, MAX_POV_SIZE};
use strum::EnumIter;
pub use sc_network::config as network;
pub use sc_network::config::RequestResponseConfig;
pub use sc_network::{config as network, config::RequestResponseConfig};
/// All requests that can be sent to the network bridge.
pub mod request;
pub use request::{IncomingRequest, OutgoingRequest, Requests, Recipient, OutgoingResult, ResponseSender};
pub use request::{
IncomingRequest, OutgoingRequest, OutgoingResult, Recipient, Requests, ResponseSender,
};
///// Multiplexer for incoming requests.
// pub mod multiplexer;
@@ -70,10 +70,9 @@ pub enum Protocol {
DisputeSending,
}
/// Minimum bandwidth we expect for validators - 500Mbit/s is the recommendation, so approximately
/// 50MB per second:
const MIN_BANDWIDTH_BYTES: u64 = 50 * 1024 * 1024;
const MIN_BANDWIDTH_BYTES: u64 = 50 * 1024 * 1024;
/// Default request timeout in seconds.
///
@@ -108,12 +107,7 @@ impl Protocol {
///
/// Returns a receiver for messages received on this protocol and the requested
/// `ProtocolConfig`.
pub fn get_config(
self,
) -> (
mpsc::Receiver<network::IncomingRequest>,
RequestResponseConfig,
) {
pub fn get_config(self) -> (mpsc::Receiver<network::IncomingRequest>, RequestResponseConfig) {
let p_name = self.into_protocol_name();
let (tx, rx) = mpsc::channel(self.get_channel_size());
let cfg = match self {
@@ -208,15 +202,16 @@ impl Protocol {
// wasting precious time.
let available_bandwidth = 7 * MIN_BANDWIDTH_BYTES / 10;
let size = u64::saturating_sub(
STATEMENTS_TIMEOUT.as_millis() as u64 * available_bandwidth / (1000 * MAX_CODE_SIZE as u64),
MAX_PARALLEL_STATEMENT_REQUESTS as u64
STATEMENTS_TIMEOUT.as_millis() as u64 * available_bandwidth /
(1000 * MAX_CODE_SIZE as u64),
MAX_PARALLEL_STATEMENT_REQUESTS as u64,
);
debug_assert!(
size > 0,
"We should have a channel size greater zero, otherwise we won't accept any requests."
);
size as usize
}
},
// Incoming requests can get bursty, we should also be able to handle them fast on
// average, so something in the ballpark of 100 should be fine. Nodes will retry on
// failure, so having a good value here is mostly about performance tuning.