Skip to content

Commit c464d0e

Browse files
committed
Make PlatformAddress implement Copy trait and remove clone() calls
1 parent 142a770 commit c464d0e

File tree

10 files changed

+15
-15
lines changed

10 files changed

+15
-15
lines changed

codechain/run_node.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,13 @@ fn new_miner(config: &config::Config, scheme: &Scheme, ap: Arc<AccountProvider>)
110110
match miner.engine_type() {
111111
EngineType::PoW => match &config.mining.author {
112112
Some(ref author) => {
113-
miner.set_author(author.address.clone(), None).expect("set_author never fails when PoW is used")
113+
miner.set_author(author.address, None).expect("set_author never fails when PoW is used")
114114
}
115115
None => return Err("mining.author is not specified".to_string()),
116116
},
117117
EngineType::InternalSealing => match &config.mining.engine_signer {
118118
Some(ref engine_signer) => {
119-
miner.set_author(engine_signer.address.clone(), None).map_err(|e| format!("{:?}", e))?
119+
miner.set_author(engine_signer.address, None).map_err(|e| format!("{:?}", e))?
120120
}
121121
None => return Err("mining.engine_signer is not specified".to_string()),
122122
},
@@ -159,7 +159,7 @@ fn load_password_file(path: Option<String>) -> Result<PasswordFile, String> {
159159

160160
fn unlock_accounts(ap: Arc<AccountProvider>, pf: &PasswordFile) -> Result<(), String> {
161161
for entry in pf.entries() {
162-
ap.unlock_account_permanently(entry.address.address.clone(), entry.password.clone())
162+
ap.unlock_account_permanently(entry.address.address, entry.password.clone())
163163
.map_err(|e| format!("Failed to unlock account {}: {}", entry.address.address, e))?;
164164
}
165165
Ok(())

codechain/subcommand/account_command.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ fn remove(ap: &AccountProvider, address: &str) -> Result<(), String> {
114114
match PlatformAddress::from_str(address) {
115115
Ok(address) => {
116116
let password = prompt_password("Password: ");
117-
match ap.remove_account(address.clone().into(), &password) {
117+
match ap.remove_account(address.into(), &password) {
118118
Ok(_) => println!("{} is deleted", address),
119119
Err(e) => return Err(format!("{:?}", e)),
120120
}

core/src/consensus/signer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl EngineSigner {
5454

5555
/// Signing address.
5656
pub fn address(&self) -> Option<Address> {
57-
self.address.clone()
57+
self.address
5858
}
5959

6060
/// Check if the given address is the signing address.

core/src/consensus/tendermint/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ impl Tendermint {
219219
} else {
220220
Err(EngineError::NotProposer(Mismatch {
221221
expected: proposer,
222-
found: address.clone(),
222+
found: *address,
223223
}))
224224
}
225225
}

core/src/consensus/vote_collector.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ impl<M: Message> StepCollector<M> {
6666
fn insert(&mut self, message: M, address: Address) -> Option<DoubleVote<M>> {
6767
// Do nothing when message was seen.
6868
if self.messages.insert(message.clone()) {
69-
if let Some(previous) = self.voted.insert(address.clone(), message.clone()) {
69+
if let Some(previous) = self.voted.insert(address, message.clone()) {
7070
// Bad validator sent a different message.
7171
return Some(DoubleVote {
72-
author: address.clone(),
72+
author: address,
7373
vote_one: previous,
7474
vote_two: message,
7575
})

core/src/miner/miner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ impl MinerService for Miner {
524524
if let Some(ref ap) = self.accounts {
525525
ctrace!(MINER, "Set author to {:?}", address);
526526
// Sign test message
527-
ap.sign(address.clone(), password.clone(), Default::default())?;
527+
ap.sign(address, password.clone(), Default::default())?;
528528
// Limit the scope of the locks.
529529
{
530530
let mut sealing_work = self.sealing_work.lock();

key/src/platform_address.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer};
2525

2626
use super::{Address, Error, NetworkId};
2727

28-
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone)]
28+
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Copy, Clone)]
2929
pub struct PlatformAddress {
3030
/// The network id of the address.
3131
pub network_id: NetworkId,

keystore/src/account/safe_account.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ impl SafeAccount {
112112
id: self.id.clone(),
113113
version: self.version.clone(),
114114
crypto: Crypto::with_secret(&secret, new_password, iterations)?,
115-
address: self.address.clone(),
115+
address: self.address,
116116
filename: self.filename.clone(),
117117
name: self.name.clone(),
118118
meta: self.meta.clone(),

keystore/src/accounts_dir/memory.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ impl KeyDirectory for MemoryDirectory {
3535

3636
fn update(&self, account: SafeAccount) -> Result<SafeAccount, Error> {
3737
let mut lock = self.accounts.write();
38-
let accounts = lock.entry(account.address.clone()).or_insert_with(Vec::new);
38+
let accounts = lock.entry(account.address).or_insert_with(Vec::new);
3939
// If the filename is the same we just need to replace the entry
4040
accounts.retain(|acc| acc.filename != account.filename);
4141
accounts.push(account.clone());
@@ -44,7 +44,7 @@ impl KeyDirectory for MemoryDirectory {
4444

4545
fn insert(&self, account: SafeAccount) -> Result<SafeAccount, Error> {
4646
let mut lock = self.accounts.write();
47-
let accounts = lock.entry(account.address.clone()).or_insert_with(Vec::new);
47+
let accounts = lock.entry(account.address).or_insert_with(Vec::new);
4848
accounts.push(account.clone());
4949
Ok(account)
5050
}

keystore/src/import.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub fn import_account(path: &Path, dst: &KeyDirectory) -> Result<Address, Error>
2929
let filename = path.file_name().and_then(|n| n.to_str()).map(|f| f.to_owned());
3030
let account = fs::File::open(&path).map_err(Into::into).and_then(|file| key_manager.read(filename, file))?;
3131

32-
let address = account.address.clone();
32+
let address = account.address;
3333
if !existing_accounts.contains(&address) {
3434
dst.insert(account)?;
3535
}
@@ -45,7 +45,7 @@ pub fn import_accounts(src: &KeyDirectory, dst: &KeyDirectory) -> Result<Vec<Add
4545
.into_iter()
4646
.filter(|a| !existing_accounts.contains(&a.address))
4747
.map(|a| {
48-
let address = a.address.clone();
48+
let address = a.address;
4949
dst.insert(a)?;
5050
Ok(address)
5151
})

0 commit comments

Comments
 (0)