Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
huitseeker committed Apr 17, 2021
1 parent 1e304d9 commit 048cc55
Show file tree
Hide file tree
Showing 14 changed files with 50 additions and 57 deletions.
5 changes: 4 additions & 1 deletion blockchain/blocks/src/election_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,10 @@ pub mod json {
vrfproof,
win_count,
} = Deserialize::deserialize(deserializer)?;
Ok(ElectionProof { win_count, vrfproof })
Ok(ElectionProof {
win_count,
vrfproof,
})
}

pub mod opt {
Expand Down
5 changes: 4 additions & 1 deletion blockchain/chain/src/store/chain_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,10 @@ pub fn genesis<DB>(db: &DB) -> Result<Option<BlockHeader>, Error>
where
DB: BlockStore,
{
Ok(db.read(GENESIS_KEY)?.map(|bz| { BlockHeader::unmarshal_cbor(&bz) }).transpose()?)
Ok(db
.read(GENESIS_KEY)?
.map(|bz| BlockHeader::unmarshal_cbor(&bz))
.transpose()?)
}

/// Attempts to deserialize to unsigend message or signed message and then returns it at as a
Expand Down
4 changes: 1 addition & 3 deletions blockchain/chain_sync/src/sync_worker/full_sync_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ async fn space_race_full_sync() {
let network = SyncNetworkContext::new(network_send, Arc::new(peer_manager), db);

let provider_db = Arc::new(MemoryDB::default());
let cids: Vec<Cid> = load_car(provider_db.as_ref(), EXPORT_SR_40)
.await
.unwrap();
let cids: Vec<Cid> = load_car(provider_db.as_ref(), EXPORT_SR_40).await.unwrap();
let prov_cs = ChainStore::new(provider_db);
let target = prov_cs
.tipset_from_keys(&TipsetKeys::new(cids))
Expand Down
4 changes: 2 additions & 2 deletions blockchain/message_pool/src/msg_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ impl MsgChain {

pub(crate) fn trim(&mut self, gas_limit: i64, base_fee: &BigInt) {
let mut i = self.chain.len() as i64 - 1;
let prev = self.prev().map(|prev| { (prev.eff_perf, prev.gas_limit) });
let prev = self.prev().map(|prev| (prev.eff_perf, prev.gas_limit));
let mut mc = self.curr_mut();
while i >= 0 && (mc.gas_limit > gas_limit || (mc.gas_perf < 0.0)) {
let gas_reward = get_gas_reward(&mc.msgs[i as usize], base_fee);
Expand Down Expand Up @@ -186,7 +186,7 @@ impl MsgChain {
}
#[allow(dead_code)]
pub(crate) fn set_eff_perf(&mut self) {
let prev = self.prev().map(|prev| { (prev.eff_perf, prev.gas_limit) });
let prev = self.prev().map(|prev| (prev.eff_perf, prev.gas_limit));

let mc = self.curr_mut();
let mut eff_perf = mc.gas_perf * mc.bp;
Expand Down
4 changes: 1 addition & 3 deletions ipld/blockstore/src/buffered.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,7 @@ mod tests {
});
let map_cid = buf_store.put(&map, Code::Blake2b256).unwrap();

let root_cid = buf_store
.put(&(map_cid, 1u8), Code::Blake2b256)
.unwrap();
let root_cid = buf_store.put(&(map_cid, 1u8), Code::Blake2b256).unwrap();

// Make sure a block not connected to the root does not get written
let unconnected = buf_store.put(&27u8, Code::Blake2b256).unwrap();
Expand Down
6 changes: 5 additions & 1 deletion node/forest_libp2p/src/chain_exchange/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,11 @@ fn fts_from_bundle_parts(
let bls_messages = values_from_indexes(&bls_msg_includes[i], &bls_msgs)?;
let secp_messages = values_from_indexes(&secp_msg_includes[i], &secp_msgs)?;

Ok(Block { header, bls_messages, secp_messages })
Ok(Block {
header,
bls_messages,
secp_messages,
})
})
.collect::<Result<_, _>>()?;

Expand Down
5 changes: 4 additions & 1 deletion vm/actor/src/builtin/miner/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3583,7 +3583,10 @@ where
let ret = rt.send(
*STORAGE_MARKET_ACTOR_ADDR,
MarketMethod::ComputeDataCommitment as u64,
Serialized::serialize(ComputeDataCommitmentParamsRef { deal_ids, sector_type })?,
Serialized::serialize(ComputeDataCommitmentParamsRef {
deal_ids,
sector_type,
})?,
TokenAmount::zero(),
)?;
let unsealed_cid: Cid = ret.deserialize()?;
Expand Down
15 changes: 3 additions & 12 deletions vm/actor/tests/alpha_beta_filter_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,18 +189,9 @@ fn values_in_range() {
(tens_of_ei_bs.clone(), one_byte_per_epoch_velocity.clone()),
(tens_of_ei_bs.clone(), ten_pi_bs_per_day_velocity.clone()),
(tens_of_ei_bs, one_ei_bs_per_day_velocity.clone()),
(
thousands_of_ei_bs.clone(),
one_byte_per_epoch_velocity,
),
(
thousands_of_ei_bs.clone(),
ten_pi_bs_per_day_velocity,
),
(
thousands_of_ei_bs,
one_ei_bs_per_day_velocity,
),
(thousands_of_ei_bs.clone(), one_byte_per_epoch_velocity),
(thousands_of_ei_bs.clone(), ten_pi_bs_per_day_velocity),
(thousands_of_ei_bs, one_ei_bs_per_day_velocity),
];

for test_case in test_cases {
Expand Down
4 changes: 1 addition & 3 deletions vm/actor/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,9 +574,7 @@ impl Runtime<MemoryDB> for MockRuntime {

match expected_msg.exit_code {
ExitCode::Ok => Ok(expected_msg.send_return),
x => {
Err(ActorError::new(x, "Expected message Fail".to_string()))
}
x => Err(ActorError::new(x, "Expected message Fail".to_string())),
}
}

Expand Down
14 changes: 4 additions & 10 deletions vm/actor/tests/init_actor_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ fn abort_cant_call_exec() {

rt.set_caller(*ACCOUNT_ACTOR_CODE_ID, anne);

let err = exec_and_verify(&mut rt, *POWER_ACTOR_CODE_ID, &"")
.expect_err("Exec should have failed");
let err =
exec_and_verify(&mut rt, *POWER_ACTOR_CODE_ID, &"").expect_err("Exec should have failed");
assert_eq!(err.exit_code(), ExitCode::ErrForbidden);
}

Expand Down Expand Up @@ -103,10 +103,7 @@ fn create_storage_miner() {
construct_and_verify(&mut rt);

// only the storage power actor can create a miner
rt.set_caller(
*POWER_ACTOR_CODE_ID,
*STORAGE_POWER_ACTOR_ADDR,
);
rt.set_caller(*POWER_ACTOR_CODE_ID, *STORAGE_POWER_ACTOR_ADDR);

let unique_address = Address::new_actor(b"miner");
rt.new_actor_addr = Some(unique_address);
Expand Down Expand Up @@ -200,10 +197,7 @@ fn sending_constructor_failure() {
construct_and_verify(&mut rt);

// Only the storage power actor can create a miner
rt.set_caller(
*POWER_ACTOR_CODE_ID,
*STORAGE_POWER_ACTOR_ADDR,
);
rt.set_caller(*POWER_ACTOR_CODE_ID, *STORAGE_POWER_ACTOR_ADDR);

// Assign new address for the storage actor miner
let unique_address = Address::new_actor(b"miner");
Expand Down
14 changes: 2 additions & 12 deletions vm/interpreter/tests/transfer_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,7 @@ fn transfer_test() {
.map_err(|e| e.to_string())
.unwrap();

let act_s = ActorState::new(
*INIT_ACTOR_CODE_ID,
state_cid,
Default::default(),
1,
);
let act_s = ActorState::new(*INIT_ACTOR_CODE_ID, state_cid, Default::default(), 1);
state.set_actor(&INIT_ACTOR_ADDR, act_s).unwrap();

let actor_addr_1 = Address::new_id(100);
Expand Down Expand Up @@ -111,12 +106,7 @@ fn transfer_test() {
10000u64.into(),
0,
);
let actor_state_2 = ActorState::new(
*ACCOUNT_ACTOR_CODE_ID,
actor_state_cid_2,
1u64.into(),
0,
);
let actor_state_2 = ActorState::new(*ACCOUNT_ACTOR_CODE_ID, actor_state_cid_2, 1u64.into(), 0);

let actor_addr_1 = state.register_new_address(&actor_addr_1).unwrap();
let actor_addr_2 = state.register_new_address(&actor_addr_2).unwrap();
Expand Down
13 changes: 12 additions & 1 deletion vm/message/src/unsigned_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,18 @@ impl<'de> Deserialize<'de> for UnsignedMessage {
method_num,
params,
) = Deserialize::deserialize(deserializer)?;
Ok(Self { version, from, to, sequence, value, method_num, params, gas_limit, gas_fee_cap, gas_premium })
Ok(Self {
version,
from,
to,
sequence,
value,
method_num,
params,
gas_limit,
gas_fee_cap,
gas_premium,
})
}
}

Expand Down
7 changes: 6 additions & 1 deletion vm/src/actor_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ pub struct ActorState {
impl ActorState {
/// Constructor for actor state
pub fn new(code: Cid, state: Cid, balance: TokenAmount, sequence: u64) -> Self {
Self { code, state, sequence, balance }
Self {
code,
state,
sequence,
balance,
}
}
/// Safely deducts funds from an Actor
pub fn deduct_funds(&mut self, amt: &TokenAmount) -> Result<(), String> {
Expand Down
7 changes: 1 addition & 6 deletions vm/state_tree/tests/state_tree_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,7 @@ fn get_set_non_id() {
.map_err(|e| e.to_string())
.unwrap();

let act_s = ActorState::new(
*INIT_ACTOR_CODE_ID,
state_cid,
Default::default(),
1,
);
let act_s = ActorState::new(*INIT_ACTOR_CODE_ID, state_cid, Default::default(), 1);

tree.snapshot().unwrap();
tree.set_actor(&INIT_ACTOR_ADDR, act_s).unwrap();
Expand Down

0 comments on commit 048cc55

Please sign in to comment.