From 60361ebe3ff832180c507170e31ee022be36af3a Mon Sep 17 00:00:00 2001 From: Dmitry Balashov <43530070+0x009922@users.noreply.github.com> Date: Fri, 16 Feb 2024 11:11:11 +0900 Subject: [PATCH] [refactor]: lints Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com> --- core/src/gossiper.rs | 6 +++--- core/src/kura.rs | 8 ++++---- core/src/sumeragi/main_loop.rs | 21 +++++++++++---------- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/core/src/gossiper.rs b/core/src/gossiper.rs index ddb81dcd310..a67709fbb9a 100644 --- a/core/src/gossiper.rs +++ b/core/src/gossiper.rs @@ -71,11 +71,11 @@ impl TransactionGossiper { let wsv = sumeragi.wsv_clone(); Self { chain_id, - queue, - sumeragi, - network, gossip_max_size, gossip_period, + queue, + network, + sumeragi, wsv, } } diff --git a/core/src/kura.rs b/core/src/kura.rs index b6319986b0d..c70e5557323 100644 --- a/core/src/kura.rs +++ b/core/src/kura.rs @@ -72,7 +72,7 @@ impl Kura { pub fn blank_kura_for_testing() -> Arc { Arc::new(Self { mode: Mode::Strict, - block_store: Mutex::new(BlockStore::new(&PathBuf::new(), LockStatus::Locked)), + block_store: Mutex::new(BlockStore::new(PathBuf::new(), LockStatus::Locked)), block_data: Mutex::new(Vec::new()), block_plain_text_path: None, }) @@ -404,8 +404,8 @@ impl BlockStore { match e.kind() { std::io::ErrorKind::AlreadyExists => Err(Error::Locked(lock_path)), std::io::ErrorKind::NotFound => { - match std::fs::create_dir_all(store_path) - .map_err(|e| Error::MkDir(e, store_path.to_path_buf())) + match std::fs::create_dir_all(store_path.as_ref()) + .map_err(|e| Error::MkDir(e, store_path.as_ref().to_path_buf())) { Err(e) => Err(e), Ok(()) => { @@ -428,7 +428,7 @@ impl BlockStore { } } BlockStore { - path_to_blockchain: store_path.to_path_buf(), + path_to_blockchain: store_path.as_ref().to_path_buf(), } } diff --git a/core/src/sumeragi/main_loop.rs b/core/src/sumeragi/main_loop.rs index 07f857bf9dd..7cde4b8c54f 100644 --- a/core/src/sumeragi/main_loop.rs +++ b/core/src/sumeragi/main_loop.rs @@ -1192,7 +1192,7 @@ mod tests { fn create_data_for_test( chain_id: &ChainId, topology: &Topology, - leader_key_pair: KeyPair, + leader_key_pair: &KeyPair, ) -> (WorldStateView, Arc, SignedBlock) { // Predefined world state let alice_id: AccountId = "alice@wonderland".parse().expect("Valid"); @@ -1225,7 +1225,7 @@ mod tests { // Creating a block of two identical transactions and validating it let block = BlockBuilder::new(vec![tx.clone(), tx], topology.clone(), Vec::new()) .chain(0, &mut wsv) - .sign(&leader_key_pair); + .sign(leader_key_pair); let genesis = block.commit(topology).expect("Block is valid"); wsv.apply(&genesis).expect("Failed to apply block"); @@ -1263,7 +1263,7 @@ mod tests { // Creating a block of two identical transactions and validating it let block = BlockBuilder::new(vec![tx1, tx2], topology.clone(), Vec::new()) .chain(0, &mut wsv.clone()) - .sign(&leader_key_pair); + .sign(leader_key_pair); (wsv, kura, block.into()) } @@ -1279,7 +1279,7 @@ mod tests { leader_key_pair.public_key().clone(), )]); let (finalized_wsv, _, mut block) = - create_data_for_test(&chain_id, &topology, leader_key_pair); + create_data_for_test(&chain_id, &topology, &leader_key_pair); let wsv = finalized_wsv.clone(); // Malform block to make it invalid @@ -1299,7 +1299,7 @@ mod tests { leader_key_pair.public_key().clone(), )]); let (finalized_wsv, kura, mut block) = - create_data_for_test(&chain_id, &topology, leader_key_pair); + create_data_for_test(&chain_id, &topology, &leader_key_pair); let mut wsv = finalized_wsv.clone(); let validated_block = @@ -1327,7 +1327,7 @@ mod tests { let topology = Topology::new(UniqueVec::new()); let leader_key_pair = KeyPair::generate().unwrap(); let (finalized_wsv, _, mut block) = - create_data_for_test(&chain_id, &topology, leader_key_pair); + create_data_for_test(&chain_id, &topology, &leader_key_pair); let wsv = finalized_wsv.clone(); // Change block height @@ -1356,7 +1356,8 @@ mod tests { "127.0.0.1:8080".parse().unwrap(), leader_key_pair.public_key().clone(), )]); - let (finalized_wsv, _, block) = create_data_for_test(&chain_id, &topology, leader_key_pair); + let (finalized_wsv, _, block) = + create_data_for_test(&chain_id, &topology, &leader_key_pair); let wsv = finalized_wsv.clone(); let result = handle_block_sync(&chain_id, block, &wsv, &finalized_wsv); assert!(matches!(result, Ok(BlockSyncOk::CommitBlock(_, _)))) @@ -1372,7 +1373,7 @@ mod tests { leader_key_pair.public_key().clone(), )]); let (finalized_wsv, kura, mut block) = - create_data_for_test(&chain_id, &topology, leader_key_pair); + create_data_for_test(&chain_id, &topology, &leader_key_pair); let mut wsv = finalized_wsv.clone(); let validated_block = @@ -1400,7 +1401,7 @@ mod tests { leader_key_pair.public_key().clone(), )]); let (finalized_wsv, kura, mut block) = - create_data_for_test(&chain_id, &topology, leader_key_pair); + create_data_for_test(&chain_id, &topology, &leader_key_pair); let mut wsv = finalized_wsv.clone(); // Increase block view change index @@ -1438,7 +1439,7 @@ mod tests { let topology = Topology::new(UniqueVec::new()); let leader_key_pair = KeyPair::generate().unwrap(); let (finalized_wsv, _, mut block) = - create_data_for_test(&chain_id, &topology, leader_key_pair); + create_data_for_test(&chain_id, &topology, &leader_key_pair); let wsv = finalized_wsv.clone(); // Change block height and view change index