Skip to content

Commit 84000b9

Browse files
Seulgi Kimsgkim126
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

0 commit comments

Comments
 (0)