Skip to content

Commit

Permalink
cargo fmt -- --config unstable_features=true --config imports_granula…
Browse files Browse the repository at this point in the history
…rity=Crate
  • Loading branch information
ma2bd committed May 26, 2021
1 parent 31d3f9f commit 23ee971
Show file tree
Hide file tree
Showing 15 changed files with 75 additions and 85 deletions.
15 changes: 6 additions & 9 deletions rust/fastpay/src/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,17 @@ extern crate fastpay_core;
extern crate log;

use fastpay::{network, transport};
use fastpay_core::authority::*;
use fastpay_core::base_types::*;
use fastpay_core::committee::*;
use fastpay_core::messages::*;
use fastpay_core::serialize::*;
use fastpay_core::{authority::*, base_types::*, committee::*, messages::*, serialize::*};

use bytes::Bytes;
use clap::{App, Arg};
use futures::stream::StreamExt;
use log::*;
use std::collections::HashMap;
use std::time::{Duration, Instant};
use tokio::runtime::Builder;
use tokio::time;
use std::{
collections::HashMap,
time::{Duration, Instant},
};
use tokio::{runtime::Builder, time};

use std::thread;

Expand Down
18 changes: 8 additions & 10 deletions rust/fastpay/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,18 @@ extern crate env_logger;
extern crate fastpay;
extern crate fastpay_core;

use fastpay::config::*;
use fastpay::{network, transport};
use fastpay_core::authority::*;
use fastpay_core::base_types::*;
use fastpay_core::client::*;
use fastpay_core::committee::Committee;
use fastpay_core::messages::*;
use fastpay_core::serialize::*;
use fastpay::{config::*, network, transport};
use fastpay_core::{
authority::*, base_types::*, client::*, committee::Committee, messages::*, serialize::*,
};

use bytes::Bytes;
use futures::stream::StreamExt;
use log::*;
use std::collections::{HashMap, HashSet};
use std::time::{Duration, Instant};
use std::{
collections::{HashMap, HashSet},
time::{Duration, Instant},
};
use structopt::StructOpt;
use tokio::runtime::Runtime;

Expand Down
20 changes: 13 additions & 7 deletions rust/fastpay/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
// Copyright (c) Facebook Inc.
// SPDX-License-Identifier: Apache-2.0

use crate::fastpay_core::base_types::*;
use crate::fastpay_core::client::ClientState;
use crate::fastpay_core::messages::{Address, CertifiedTransferOrder};
use crate::transport::NetworkProtocol;
use crate::{
fastpay_core::{
base_types::*,
client::ClientState,
messages::{Address, CertifiedTransferOrder},
},
transport::NetworkProtocol,
};

use serde::{Deserialize, Serialize};
use std::collections::BTreeMap;
use std::fs::{self, File, OpenOptions};
use std::io::{BufRead, BufReader, BufWriter, Write};
use std::{
collections::BTreeMap,
fs::{self, File, OpenOptions},
io::{BufRead, BufReader, BufWriter, Write},
};

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct AuthorityConfig {
Expand Down
12 changes: 2 additions & 10 deletions rust/fastpay/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,10 @@
// SPDX-License-Identifier: Apache-2.0

use crate::transport::*;
use fastpay_core::authority::*;
use fastpay_core::base_types::*;
use fastpay_core::client::*;
use fastpay_core::error::*;
use fastpay_core::messages::*;
use fastpay_core::serialize::*;
use fastpay_core::{authority::*, base_types::*, client::*, error::*, messages::*, serialize::*};

use bytes::Bytes;
use futures::channel::mpsc;
use futures::future::FutureExt;
use futures::sink::SinkExt;
use futures::stream::StreamExt;
use futures::{channel::mpsc, future::FutureExt, sink::SinkExt, stream::StreamExt};
use log::*;
use std::io;
use tokio::time;
Expand Down
8 changes: 2 additions & 6 deletions rust/fastpay/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@ extern crate env_logger;
extern crate fastpay;
extern crate fastpay_core;

use fastpay::config::*;
use fastpay::network;
use fastpay::transport;
use fastpay_core::authority::*;
use fastpay_core::base_types::*;
use fastpay_core::committee::Committee;
use fastpay::{config::*, network, transport};
use fastpay_core::{authority::*, base_types::*, committee::Committee};

use futures::future::join_all;
use log::*;
Expand Down
12 changes: 5 additions & 7 deletions rust/fastpay/src/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ use clap::arg_enum;
use futures::future;
use log::*;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::convert::TryInto;
use std::io;
use std::sync::Arc;
use tokio::net::TcpListener;
use tokio::net::{TcpStream, UdpSocket};
use tokio::prelude::*;
use std::{collections::HashMap, convert::TryInto, io, sync::Arc};
use tokio::{
net::{TcpListener, TcpStream, UdpSocket},
prelude::*,
};

#[cfg(test)]
#[path = "unit_tests/transport_tests.rs"]
Expand Down
9 changes: 5 additions & 4 deletions rust/fastpay/src/unit_tests/transport_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
// SPDX-License-Identifier: Apache-2.0

use super::*;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::time::Duration;
use tokio::runtime::Runtime;
use tokio::time::timeout;
use std::{
sync::atomic::{AtomicUsize, Ordering},
time::Duration,
};
use tokio::{runtime::Runtime, time::timeout};

async fn get_new_local_address() -> Result<String, std::io::Error> {
let builder = net2::TcpBuilder::new_v4()?;
Expand Down
8 changes: 2 additions & 6 deletions rust/fastpay_core/src/authority.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
// Copyright (c) Facebook Inc.
// SPDX-License-Identifier: Apache-2.0

use crate::base_types::*;
use crate::committee::Committee;
use crate::error::FastPayError;
use crate::messages::*;
use std::collections::BTreeMap;
use std::convert::TryInto;
use crate::{base_types::*, committee::Committee, error::FastPayError, messages::*};
use std::{collections::BTreeMap, convert::TryInto};

#[cfg(test)]
#[path = "unit_tests/authority_tests.rs"]
Expand Down
12 changes: 5 additions & 7 deletions rust/fastpay_core/src/client.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
// Copyright (c) Facebook Inc.
// SPDX-License-Identifier: Apache-2.0

use crate::base_types::*;
use crate::committee::Committee;
use crate::downloader::*;
use crate::error::FastPayError;
use crate::messages::*;
use crate::{base_types::*, committee::Committee, downloader::*, error::FastPayError, messages::*};

use futures::{future, StreamExt};
use rand::seq::SliceRandom;
use std::collections::{btree_map, BTreeMap, BTreeSet, HashMap};
use std::convert::TryFrom;
use std::{
collections::{btree_map, BTreeMap, BTreeSet, HashMap},
convert::TryFrom,
};

#[cfg(test)]
#[path = "unit_tests/client_tests.rs"]
Expand Down
6 changes: 4 additions & 2 deletions rust/fastpay_core/src/downloader.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// Copyright (c) Facebook Inc.
// SPDX-License-Identifier: Apache-2.0

use futures::channel::{mpsc, oneshot};
use futures::{future, SinkExt, StreamExt};
use futures::{
channel::{mpsc, oneshot},
future, SinkExt, StreamExt,
};
use std::collections::BTreeMap;

#[cfg(test)]
Expand Down
8 changes: 5 additions & 3 deletions rust/fastpay_core/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// Copyright (c) Facebook Inc.
// SPDX-License-Identifier: Apache-2.0

use crate::base_types::*;
use crate::messages::*;
use crate::serde::{Deserialize, Serialize};
use crate::{
base_types::*,
messages::*,
serde::{Deserialize, Serialize},
};

#[macro_export]
macro_rules! fp_bail {
Expand Down
4 changes: 1 addition & 3 deletions rust/fastpay_core/src/fastpay_smart_contract.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// Copyright (c) Facebook Inc.
// SPDX-License-Identifier: Apache-2.0

use super::base_types::*;
use super::committee::Committee;
use super::messages::*;
use super::{base_types::*, committee::Committee, messages::*};
use std::collections::BTreeMap;

#[cfg(test)]
Expand Down
10 changes: 5 additions & 5 deletions rust/fastpay_core/src/messages.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// Copyright (c) Facebook Inc.
// SPDX-License-Identifier: Apache-2.0

use super::base_types::*;
use super::committee::Committee;
use super::error::*;
use super::{base_types::*, committee::Committee, error::*};

use ed25519_dalek::{Digest, Sha512};

Expand All @@ -12,8 +10,10 @@ use ed25519_dalek::{Digest, Sha512};
mod messages_tests;

use serde::{Deserialize, Serialize};
use std::collections::HashSet;
use std::hash::{Hash, Hasher};
use std::{
collections::HashSet,
hash::{Hash, Hasher},
};

#[derive(Eq, PartialEq, Clone, Debug, Serialize, Deserialize)]
pub struct FundingTransaction {
Expand Down
12 changes: 8 additions & 4 deletions rust/fastpay_core/src/unit_tests/client_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
#![allow(clippy::same_item_push)] // get_key_pair returns random elements

use super::*;
use crate::authority::{AccountOffchainState, Authority, AuthorityState};
use crate::base_types::Amount;
use crate::{
authority::{AccountOffchainState, Authority, AuthorityState},
base_types::Amount,
};
use futures::lock::Mutex;
use std::collections::{BTreeMap, HashMap};
use std::sync::Arc;
use std::{
collections::{BTreeMap, HashMap},
sync::Arc,
};
use tokio::runtime::Runtime;

#[derive(Clone)]
Expand Down
6 changes: 4 additions & 2 deletions rust/fastpay_core/src/unit_tests/downloader_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@

use super::*;
use futures::future;
use std::sync::atomic::{AtomicU32, Ordering};
use std::sync::Arc;
use std::sync::{
atomic::{AtomicU32, Ordering},
Arc,
};
use tokio::runtime::Runtime;

#[derive(Clone)]
Expand Down

0 comments on commit 23ee971

Please sign in to comment.