Rustify core/src/core (#1122)

Small refactoring of one folder, if it makes sense I could extend the scope.
* Remove some cloning (real and just verbosity in the code)
* Naming conventions like to/into*
* Some Clippy's suggestions

I found that we don't use field init shorthand syntax, so I didn't touch this part, was it discussed before?
This commit is contained in:
hashmap
2018-06-01 21:41:26 +02:00
committed by Yeastplume
parent 7812a02233
commit 2fa32d15ce
27 changed files with 215 additions and 263 deletions
+4 -3
View File
@@ -19,8 +19,8 @@ use std::sync::{Arc, RwLock};
use rand::Rng;
use rand::os::OsRng;
use core::core::target::Difficulty;
use core::core::hash::Hash;
use core::core::target::Difficulty;
use msg::*;
use peer::Peer;
use types::*;
@@ -35,7 +35,8 @@ pub struct Handshake {
/// a node id.
nonces: Arc<RwLock<VecDeque<u64>>>,
/// The genesis block header of the chain seen by this node.
/// We only want to connect to other nodes seeing the same chain (forks are ok).
/// We only want to connect to other nodes seeing the same chain (forks are
/// ok).
genesis: Hash,
config: P2PConfig,
}
@@ -111,7 +112,7 @@ impl Handshake {
debug!(
LOGGER,
"Connected! Cumulative {} offered from {:?} {:?} {:?}",
peer_info.total_difficulty.into_num(),
peer_info.total_difficulty.to_num(),
peer_info.addr,
peer_info.user_agent,
peer_info.capabilities
+1 -1
View File
@@ -686,7 +686,7 @@ impl NetAdapter for Peers {
);
}
if diff.into_num() > 0 {
if diff.to_num() > 0 {
if let Some(peer) = self.get_connected_peer(&addr) {
let mut peer = peer.write().unwrap();
peer.info.total_difficulty = diff;