Skip to content

Commit 84000b9

Browse files
Seulgi Kimsgkim126
Seulgi Kim
authored andcommitted
Update rustfmt
1 parent cf6206a commit 84000b9

File tree

22 files changed

+91
-62
lines changed

22 files changed

+91
-62
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ language: rust
22
rust:
33
- stable
44
install:
5-
- rustup toolchain install nightly-2018-05-07
6-
- rustup component add rustfmt-preview --toolchain nightly-2018-05-07
5+
- rustup toolchain install nightly-2018-07-17
6+
- rustup component add rustfmt-preview --toolchain nightly-2018-07-17
77
before_script:
88
- cargo fetch --verbose
99
script:
10-
- cargo +nightly-2018-05-07 fmt -- --write-mode=diff
10+
- cargo +nightly-2018-07-17 fmt -- --check
1111
- RUST_BACKTRACE=1 cargo test --verbose --all
1212
matrix:
1313
allow_failures:

codechain/main.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,10 +249,12 @@ fn run_node(matches: ArgMatches) -> Result<(), String> {
249249
let config = load_config(&matches)?;
250250
let spec = config.operating.chain.spec()?;
251251

252-
let instance_id = config.operating.instance_id.unwrap_or(SystemTime::now()
253-
.duration_since(UNIX_EPOCH)
254-
.expect("Current time should be later than unix epoch")
255-
.subsec_nanos() as usize);
252+
let instance_id = config.operating.instance_id.unwrap_or(
253+
SystemTime::now()
254+
.duration_since(UNIX_EPOCH)
255+
.expect("Current time should be later than unix epoch")
256+
.subsec_nanos() as usize,
257+
);
256258
clogger::init(&LoggerConfig::new(instance_id)).expect("Logger must be successfully initialized");
257259

258260
// FIXME: Handle IO error.

core/src/blockchain/extras.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,8 @@ impl BlockInvoices {
264264

265265
impl Decodable for BlockInvoices {
266266
fn decode(rlp: &UntrustedRlp) -> Result<Self, DecoderError> {
267-
let invoices = rlp.as_list::<Vec<u8>>()?
267+
let invoices = rlp
268+
.as_list::<Vec<u8>>()?
268269
.iter()
269270
.map(|parcel_invoice| UntrustedRlp::new(&parcel_invoice).as_val::<ParcelInvoice>())
270271
.collect::<Result<Vec<_>, _>>()?;

core/src/consensus/mod.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,4 @@ pub trait CodeChainEngine: ConsensusEngine<CodeChainMachine> {
325325
}
326326

327327
// convenience wrappers for existing functions.
328-
impl<T> CodeChainEngine for T
329-
where
330-
T: ConsensusEngine<CodeChainMachine>,
331-
{
332-
}
328+
impl<T> CodeChainEngine for T where T: ConsensusEngine<CodeChainMachine> {}

core/src/consensus/tendermint/mod.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,8 @@ impl Tendermint {
239239

240240
/// Broadcast all messages since last issued block to get the peers up to speed.
241241
fn broadcast_old_messages(&self) {
242-
for m in self.votes
242+
for m in self
243+
.votes
243244
.get_up_to(&VoteStep::new(
244245
self.height.load(AtomicOrdering::SeqCst),
245246
self.view.load(AtomicOrdering::SeqCst),
@@ -359,7 +360,9 @@ impl Tendermint {
359360
Some(lock) => vote_step > &lock.vote_step,
360361
None => true,
361362
};
362-
let lock_change = is_newer_than_lock && vote_step.step == Step::Prevote && message.block_hash.is_some()
363+
let lock_change = is_newer_than_lock
364+
&& vote_step.step == Step::Prevote
365+
&& message.block_hash.is_some()
363366
&& self.has_enough_aligned_votes(message);
364367
if lock_change {
365368
ctrace!(ENGINE, "handle_valid_message: Lock change.");

core/src/miner/local_parcels.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ impl LocalParcelsList {
150150
return
151151
}
152152

153-
let to_remove = self.parcels
153+
let to_remove = self
154+
.parcels
154155
.iter()
155156
.filter(|&(_, status)| !status.is_current())
156157
.map(|(hash, _)| *hash)

core/src/miner/mem_pool.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,8 @@ impl ParcelSet {
263263
};
264264

265265
Some(to_drop.into_iter().fold(HashMap::new(), |mut removed, (sender, nonce)| {
266-
let order = self.drop(&sender, &nonce)
266+
let order = self
267+
.drop(&sender, &nonce)
267268
.expect("Parcel has just been found in `by_priority`; so it is in `by_address` also.");
268269
ctrace!(MEM_POOL, "Dropped out of limit parcel: {:?}", order.hash);
269270

@@ -469,7 +470,8 @@ impl MemPool {
469470
pub fn remove_old<F>(&mut self, fetch_account: &F, current_time: PoolingInstant)
470471
where
471472
F: Fn(&Address) -> AccountDetails, {
472-
let senders = self.current
473+
let senders = self
474+
.current
473475
.by_address
474476
.keys()
475477
.chain(self.future.by_address.keys())
@@ -483,7 +485,8 @@ impl MemPool {
483485
let max_time = self.max_time_in_pool;
484486
let balance_check = max_time >> 3;
485487
// Clear parcels occupying the pool too long
486-
let invalid = self.by_hash
488+
let invalid = self
489+
.by_hash
487490
.iter()
488491
.filter(|&(_, ref parcel)| !parcel.origin.is_local())
489492
.map(|(hash, parcel)| (hash, parcel, current_time.saturating_sub(parcel.insertion_time)))
@@ -931,7 +934,8 @@ impl MemPool {
931934
fn mark_parcels_local(&mut self, sender: &Address) {
932935
fn mark_local<F: FnMut(H256)>(sender: &Address, set: &mut ParcelSet, mut mark: F) {
933936
// Mark all parcels from this sender as local
934-
let nonces_from_sender = set.by_address
937+
let nonces_from_sender = set
938+
.by_address
935939
.row(sender)
936940
.map(|row_map| {
937941
row_map

core/src/miner/miner.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ impl Miner {
161161
if sealing_work.enabled {
162162
ctrace!(MINER, "requires_reseal: sealing enabled");
163163
let last_request = *self.sealing_block_last_request.lock();
164-
let should_disable_sealing = !self.options.force_sealing && !has_local_parcels
164+
let should_disable_sealing = !self.options.force_sealing
165+
&& !has_local_parcels
165166
&& self.engine.seals_internally().is_none()
166167
&& best_block > last_request
167168
&& best_block - last_request > SEALING_TIMEOUT_IN_BLOCKS;
@@ -209,7 +210,8 @@ impl Miner {
209210
cdebug!(MINER, "Rejected parcel {:?}: already in the blockchain", hash);
210211
return Err(Error::Parcel(ParcelError::AlreadyImported))
211212
}
212-
match self.engine
213+
match self
214+
.engine
213215
.verify_parcel_basic(&parcel, &best_block_header)
214216
.and_then(|_| self.engine.verify_parcel_unordered(parcel, &best_block_header))
215217
{
@@ -221,7 +223,8 @@ impl Miner {
221223
// This check goes here because verify_parcel takes SignedParcel parameter
222224
self.engine.machine().verify_parcel(&parcel, &best_block_header, client)?;
223225

224-
let origin = self.accounts
226+
let origin = self
227+
.accounts
225228
.as_ref()
226229
.and_then(|accounts| match accounts.has_account(parcel.sender()) {
227230
Ok(true) => Some(ParcelOrigin::Local),
@@ -419,7 +422,8 @@ impl Miner {
419422
fn seal_and_import_block_internally<C>(&self, chain: &C, block: ClosedBlock) -> bool
420423
where
421424
C: BlockChain + ImportSealedBlock, {
422-
if block.parcels().is_empty() && !self.options.force_sealing
425+
if block.parcels().is_empty()
426+
&& !self.options.force_sealing
423427
&& Instant::now() <= *self.next_mandatory_reseal.read()
424428
{
425429
return false
@@ -701,7 +705,8 @@ impl MinerService for Miner {
701705
// Be sure to release the lock before we call prepare_work_sealing
702706
let mut mem_pool = self.mem_pool.write();
703707
// We need to re-validate parcels
704-
let import = self.add_parcels_to_pool(chain, vec![parcel.into()], ParcelOrigin::Local, &mut mem_pool)
708+
let import = self
709+
.add_parcels_to_pool(chain, vec![parcel.into()], ParcelOrigin::Local, &mut mem_pool)
705710
.pop()
706711
.expect("one result returned per added parcel; one added => one result; qed");
707712

core/src/miner/work_notify.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ pub struct WorkPoster {
4242
impl WorkPoster {
4343
/// Create new `WorkPoster`.
4444
pub fn new(urls: &[String]) -> Self {
45-
let urls = urls.into_iter()
45+
let urls = urls
46+
.into_iter()
4647
.filter_map(|u| match Url::parse(u) {
4748
Ok(url) => Some(url),
4849
Err(e) => {

core/src/service.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ impl ClientService {
4848
db_config.compaction = config.db_compaction.compaction_profile(client_path);
4949
db_config.wal = config.db_wal;
5050

51-
let db = Arc::new(Database::open(
52-
&db_config,
53-
&client_path.to_str().expect("DB path could not be converted to string."),
54-
).map_err(::client::Error::Database)?);
51+
let db = Arc::new(
52+
Database::open(&db_config, &client_path.to_str().expect("DB path could not be converted to string."))
53+
.map_err(::client::Error::Database)?,
54+
);
5555

5656
let client = Client::new(config, &spec, db, miner, io_service.channel())?;
5757

core/src/state/shard_level.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,8 @@ impl<B: Backend + ShardBackend> ShardStateInternal for ShardLevelState<B> {
334334
let asset_type = input.prev_out.asset_type.clone();
335335
let asset_scheme_address = AssetSchemeAddress::from_hash(asset_type)
336336
.ok_or(TransactionError::AssetSchemeNotFound(asset_type.into()))?;
337-
let _asset_scheme = self.asset_scheme((&asset_scheme_address).into())?
337+
let _asset_scheme = self
338+
.asset_scheme((&asset_scheme_address).into())?
338339
.ok_or(TransactionError::AssetSchemeNotFound(asset_scheme_address.into()))?;
339340

340341
match self.asset(&address)? {

core/src/state_db.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,10 @@ impl StateDB {
131131
pub fn new(db: Box<JournalDB>, cache_size: usize) -> StateDB {
132132
assert_eq!(
133133
100,
134-
ACCOUNT_CACHE_RATIO + METADATA_CACHE_RATIO + SHARD_CACHE_RATIO + ASSET_SCHEME_CACHE_RATIO
134+
ACCOUNT_CACHE_RATIO
135+
+ METADATA_CACHE_RATIO
136+
+ SHARD_CACHE_RATIO
137+
+ ASSET_SCHEME_CACHE_RATIO
135138
+ ASSET_CACHE_RATIO
136139
);
137140

@@ -411,7 +414,8 @@ impl StateDB {
411414
/// Heap size used.
412415
pub fn mem_used(&self) -> usize {
413416
// TODO: account for LRU-cache overhead; this is a close approximation.
414-
self.db.mem_used() + Self::mem_used_impl(&self.account_cache.lock())
417+
self.db.mem_used()
418+
+ Self::mem_used_impl(&self.account_cache.lock())
415419
+ Self::mem_used_impl(&self.shard_cache.lock())
416420
+ Self::mem_used_impl(&self.asset_scheme_cache.lock())
417421
+ Self::mem_used_impl(&self.asset_cache.lock())

keystore/src/accounts_dir/disk.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,8 @@ where
231231
fn remove(&self, account: &SafeAccount) -> Result<(), Error> {
232232
// enumerate all entries in keystore
233233
// and find entry with given address
234-
let to_remove = self.files_content()?
234+
let to_remove = self
235+
.files_content()?
235236
.into_iter()
236237
.find(|&(_, ref acc)| acc.id == account.id && acc.address == account.address);
237238

network/src/p2p/handler.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ impl Manager {
136136

137137
let local_node_id =
138138
self.routing_table.local_node_id(&remote_node_id).ok_or(Error::General("Not handshaked"))?;
139-
let session = self.routing_table
139+
let session = self
140+
.routing_table
140141
.unestablished_session(&socket_address)
141142
.ok_or(Error::General("Session doesn't exist"))?;
142143

@@ -210,7 +211,8 @@ impl Manager {
210211
node_id,
211212
..
212213
}) => {
213-
let remote_addr = self.connections
214+
let remote_addr = self
215+
.connections
214216
.remote_addr_of_waiting_sync(stream)
215217
.ok_or(Error::General("Cannot find remote address"))?;
216218
let remote_node_id = convert_to_node_id(remote_addr.ip(), port);
@@ -223,7 +225,8 @@ impl Manager {
223225
}
224226

225227
let remote_addr = SocketAddr::new(remote_addr.ip(), port);
226-
let session = self.routing_table
228+
let session = self
229+
.routing_table
227230
.unestablished_session(&remote_addr)
228231
.ok_or(Error::General("Cannot find session"))?;
229232
if !signed_message.is_valid(&session) {

network/src/session_initiator/handler.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,8 @@ impl SessionInitiator {
267267
let message = message::Message::nonce_request(seq as u64, encrypted_nonce);
268268
self.server.enqueue(message, from.clone())?;
269269
} else {
270-
let requester_pub_key = self.routing_table
270+
let requester_pub_key = self
271+
.routing_table
271272
.register_key_pair_for_secret(from)
272273
.ok_or(Error::General("Cannot register key pair"))?;
273274

@@ -303,7 +304,8 @@ impl SessionInitiator {
303304
return Ok(())
304305
}
305306

306-
let _secret = self.routing_table
307+
let _secret = self
308+
.routing_table
307309
.share_secret(from, responder_pub_key)
308310
.ok_or(Error::General("Cannot share secret"))?;
309311
let encrypted_nonce =

rpc/src/v1/impls/account.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ impl Account for AccountClient {
4242
}
4343

4444
fn create_account(&self, passphrase: Option<String>) -> Result<Address> {
45-
let (address, _) = self.account_provider
45+
let (address, _) = self
46+
.account_provider
4647
.new_account_and_public(passphrase.unwrap_or_default().as_ref())
4748
.map_err(account_provider)?;
4849
Ok(address)

rustfmt.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
indent_style = "Block"
2-
use_small_heuristics = false # true
2+
use_small_heuristics = "Off" # "Default"
33
binop_separator = "Front"
44
# combine_control_expr = true
55
comment_width = 120 # 80
@@ -18,12 +18,14 @@ format_strings = false
1818
hard_tabs = false
1919
imports_indent = "Block" # "Visual"
2020
imports_layout = "Mixed"
21+
merge_imports = false
2122
match_block_trailing_comma = false
2223
max_width = 120 # 100
2324
merge_derives = true
2425
# force_multiline_blocks = false
2526
newline_style = "Unix"
2627
normalize_comments = false
28+
remove_nested_parens = true
2729
reorder_imports = true
2830
reorder_modules = true
2931
# reorder_impl_items = false
@@ -34,7 +36,6 @@ space_after_colon = true
3436
space_before_colon = false
3537
struct_field_align_threshold = 0
3638
spaces_around_ranges = false
37-
spaces_within_parens_and_brackets = false
3839
## struct_lit_single_line = true
3940
tab_spaces = 4
4041
trailing_comma = "Vertical"
@@ -44,10 +45,8 @@ use_field_init_shorthand = true # false
4445
use_try_shorthand = true # false
4546
wrap_comments = false
4647
match_arm_blocks = true
47-
write_mode = "Overwrite"
4848
blank_lines_upper_bound = 2 # 1
4949
blank_lines_lower_bound = 0
50-
remove_blank_lines_at_start_or_end_of_block = true
5150
hide_parse_errors = false
5251
color = "Always" # "Auto"
5352
unstable_features = false

types/src/transaction/transaction.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@ impl Encodable for Transaction {
177177
},
178178
registrar,
179179
nonce,
180-
} => s.begin_list(8)
180+
} => s
181+
.begin_list(8)
181182
.append(&ASSET_MINT_ID)
182183
.append(network_id)
183184
.append(metadata)
@@ -192,7 +193,8 @@ impl Encodable for Transaction {
192193
inputs,
193194
outputs,
194195
nonce,
195-
} => s.begin_list(6)
196+
} => s
197+
.begin_list(6)
196198
.append(&ASSET_TRANSFER_ID)
197199
.append(network_id)
198200
.append_list(burns)

util/io/src/service.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,8 @@ where
306306
IoMessage::AddHandler {
307307
handler,
308308
} => {
309-
let handler_id = self.handlers
309+
let handler_id = self
310+
.handlers
310311
.write()
311312
.insert(handler.clone())
312313
.unwrap_or_else(|_| panic!("Too many handlers registered"));

0 commit comments

Comments
 (0)