Eliminated connection loops.
Optimized network processes. Removed some unnecessary logging. Fixed status bar info inconsistency.
This commit is contained in:
+7
-2
@@ -2,13 +2,14 @@ use std::net::SocketAddr;
|
||||
use std::collections::HashMap;
|
||||
use mio::net::TcpStream;
|
||||
use crate::p2p::State;
|
||||
use crate::Block;
|
||||
use crate::{Block, commons};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Peer {
|
||||
addr: SocketAddr,
|
||||
stream: TcpStream,
|
||||
state: State,
|
||||
rand: String,
|
||||
height: u64,
|
||||
inbound: bool,
|
||||
public: bool,
|
||||
@@ -19,7 +20,7 @@ pub struct Peer {
|
||||
|
||||
impl Peer {
|
||||
pub fn new(addr: SocketAddr, stream: TcpStream, state: State, inbound: bool) -> Self {
|
||||
Peer { addr, stream, state, height: 0, inbound, public: false, active: false, received_block: 0, fork: HashMap::new() }
|
||||
Peer { addr, stream, state, rand: commons::random_string(6), height: 0, inbound, public: false, active: false, received_block: 0, fork: HashMap::new() }
|
||||
}
|
||||
|
||||
pub fn get_addr(&self) -> SocketAddr {
|
||||
@@ -42,6 +43,10 @@ impl Peer {
|
||||
self.state = state;
|
||||
}
|
||||
|
||||
pub fn get_rand(&self) -> &str {
|
||||
&self.rand
|
||||
}
|
||||
|
||||
pub fn set_height(&mut self, height: u64) {
|
||||
self.height = height;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user