Skip to content

Commit 72cfa35

Browse files
committed
chore: make fmt pass
1 parent f4f1c62 commit 72cfa35

File tree

7 files changed

+43
-27
lines changed

7 files changed

+43
-27
lines changed

data_structures/src/chain/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ impl ConsensusConstantsWit2 {
318318
4u16.saturating_mul(2u16.saturating_pow(epoch - prev_epoch))
319319
} else {
320320
0
321-
}
321+
};
322322
} else {
323323
0
324324
}

data_structures/src/staking/stakes.rs

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,10 @@ where
326326
self.by_key
327327
.iter()
328328
.map(move |(key, entry)| {
329-
(key.clone(), entry.read_value().power(capability, current_epoch))
329+
(
330+
key.clone(),
331+
entry.read_value().power(capability, current_epoch),
332+
)
330333
})
331334
.sorted_by(|(key_1, power_1), (key_2, power_2)| {
332335
if power_1 == power_2 {
@@ -417,7 +420,7 @@ where
417420
pub fn reset_mining_age<ISK>(
418421
&mut self,
419422
validator: ISK,
420-
current_epoch: Epoch
423+
current_epoch: Epoch,
421424
) -> StakesResult<(), Address, Coins, Epoch>
422425
where
423426
ISK: Into<Address>,
@@ -427,15 +430,15 @@ where
427430
// order mining stake entries by rank, as for given current_epoch:
428431
// let stakes_clone = self.clone();
429432
let by_rank = self.by_rank(Capability::Mining, current_epoch);
430-
433+
431434
// locate first entry whose validator matches the one searched for:
432-
let winner_rank = by_rank.clone().position(|(key, _)| key.validator == validator);
433-
435+
let winner_rank = by_rank
436+
.clone()
437+
.position(|(key, _)| key.validator == validator);
438+
434439
if let Some(winner_rank) = winner_rank {
435-
let stakers: Vec<StakeKey<Address>> = by_rank
436-
.take(winner_rank + 1)
437-
.map(|(key, _)| key)
438-
.collect();
440+
let stakers: Vec<StakeKey<Address>> =
441+
by_rank.take(winner_rank + 1).map(|(key, _)| key).collect();
439442
// proportionally reset coin age on located entry and all those with a better mining rank:
440443
let mut index: usize = 0;
441444
stakers.iter().for_each(|key| {
@@ -444,7 +447,10 @@ where
444447
let penalty_epochs = Epoch::from((1 + winner_rank - index) as u32);
445448
log::debug!(
446449
"Resetting mining power of {} (ranked as #{}) during +{} epochs to {}",
447-
key, index + 1, penalty_epochs, current_epoch + penalty_epochs
450+
key,
451+
index + 1,
452+
penalty_epochs,
453+
current_epoch + penalty_epochs
448454
);
449455
stake_entry
450456
.value
@@ -1140,7 +1146,9 @@ mod tests {
11401146
]
11411147
);
11421148
assert_eq!(
1143-
stakes.by_rank(Capability::Witnessing, 100).collect::<Vec<_>>(),
1149+
stakes
1150+
.by_rank(Capability::Witnessing, 100)
1151+
.collect::<Vec<_>>(),
11441152
[
11451153
(charlie_erin.into(), 2100),
11461154
(bob_david.into(), 1600),
@@ -1179,7 +1187,9 @@ mod tests {
11791187
]
11801188
);
11811189
assert_eq!(
1182-
stakes.by_rank(Capability::Witnessing, 101).collect::<Vec<_>>(),
1190+
stakes
1191+
.by_rank(Capability::Witnessing, 101)
1192+
.collect::<Vec<_>>(),
11831193
[
11841194
(charlie_erin.into(), 2_130),
11851195
(bob_david.into(), 1_620),
@@ -1220,7 +1230,9 @@ mod tests {
12201230
]
12211231
);
12221232
assert_eq!(
1223-
stakes.by_rank(Capability::Witnessing, 300).collect::<Vec<_>>(),
1233+
stakes
1234+
.by_rank(Capability::Witnessing, 300)
1235+
.collect::<Vec<_>>(),
12241236
[
12251237
(charlie_erin.into(), 8_100),
12261238
(bob_david.into(), 5_600),

node/src/actors/chain_manager/handlers.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ use witnet_data_structures::{
1515
Hash, Hashable, NodeStats, PublicKeyHash, SuperBlockVote, SupplyInfo, ValueTransferOutput,
1616
},
1717
error::{ChainInfoError, TransactionError::DataRequestNotFound},
18-
get_protocol_version,
19-
refresh_protocol_version,
18+
get_protocol_version, refresh_protocol_version,
2019
staking::{errors::StakesError, prelude::StakeKey},
2120
transaction::{
2221
DRTransaction, StakeTransaction, Transaction, UnstakeTransaction, VTTransaction,

node/src/actors/chain_manager/mining.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,10 @@ impl ChainManager {
120120
vrf_input.checkpoint = current_epoch;
121121

122122
let target_hash = if protocol_version == V2_0 {
123-
let replication_factor = self
124-
.consensus_constants_wit2
125-
.get_replication_factor(current_epoch, chain_info.highest_block_checkpoint.checkpoint);
123+
let replication_factor = self.consensus_constants_wit2.get_replication_factor(
124+
current_epoch,
125+
chain_info.highest_block_checkpoint.checkpoint,
126+
);
126127
let eligibility = self
127128
.chain_state
128129
.stakes

node/src/actors/chain_manager/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3128,7 +3128,10 @@ pub fn process_validations(
31283128
stakes: &StakesTracker,
31293129
protocol_version: ProtocolVersion,
31303130
) -> Result<Diff, failure::Error> {
3131-
let replication_factor = consensus_constants_wit2.get_replication_factor(block.block_header.beacon.checkpoint, chain_beacon.checkpoint);
3131+
let replication_factor = consensus_constants_wit2.get_replication_factor(
3132+
block.block_header.beacon.checkpoint,
3133+
chain_beacon.checkpoint,
3134+
);
31323135
if !resynchronizing {
31333136
let mut signatures_to_verify = vec![];
31343137
validate_block(

node/src/actors/session/handlers.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use std::{cmp::Ordering, convert::TryFrom, io::Error, net::SocketAddr};
22

33
use actix::{
4-
ActorContext, ActorFutureExt, ActorTryFutureExt, Context, ContextFutureSpawner,
5-
Handler, io::WriteHandler, StreamHandler, SystemService, WrapFuture,
4+
io::WriteHandler, ActorContext, ActorFutureExt, ActorTryFutureExt, Context,
5+
ContextFutureSpawner, Handler, StreamHandler, SystemService, WrapFuture,
66
};
77
use bytes::BytesMut;
88
use failure::Fail;
@@ -749,7 +749,6 @@ fn inventory_process_block(session: &mut Session, _ctx: &mut Context<Session>, b
749749
// that uses a newer version.
750750
session.blocks_timestamp = 0;
751751
session.requested_blocks.clear();
752-
753752
}
754753
} else {
755754
// If this is not a requested block, assume it is a candidate

validations/src/eligibility/current.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,21 +176,23 @@ where
176176
let validator: Address = validator.into();
177177

178178
// Cap replication factor to 2/3rds of total stake entries count
179-
let max_replication_factor = u16::try_from((((self.stakes_count() * 2) as f64) / 3.0) as u32).unwrap_or(u16::MAX);
179+
let max_replication_factor =
180+
u16::try_from((((self.stakes_count() * 2) as f64) / 3.0) as u32).unwrap_or(u16::MAX);
180181
let replication_factor = if replication_factor > max_replication_factor {
181182
max_replication_factor
182183
} else {
183184
replication_factor
184185
};
185186

186187
Ok(
187-
match self.by_rank(Capability::Mining, epoch)
188+
match self
189+
.by_rank(Capability::Mining, epoch)
188190
.take(replication_factor as usize)
189191
.find(|(key, _)| key.validator == validator)
190192
{
191193
Some(_) => Eligible::Yes,
192-
None => IneligibilityReason::InsufficientPower.into()
193-
}
194+
None => IneligibilityReason::InsufficientPower.into(),
195+
},
194196
)
195197
}
196198

0 commit comments

Comments
 (0)