Speedup initial blockchain receiving.
This commit is contained in:
+10
-1
@@ -7,13 +7,14 @@ pub struct Peer {
|
||||
addr: SocketAddr,
|
||||
stream: TcpStream,
|
||||
state: State,
|
||||
height: u64,
|
||||
inbound: bool,
|
||||
public: bool,
|
||||
}
|
||||
|
||||
impl Peer {
|
||||
pub fn new(addr: SocketAddr, stream: TcpStream, state: State, inbound: bool) -> Self {
|
||||
Peer { addr, stream, state, inbound, public: false }
|
||||
Peer { addr, stream, state, height: 0, inbound, public: false }
|
||||
}
|
||||
|
||||
pub fn get_addr(&self) -> SocketAddr {
|
||||
@@ -36,6 +37,14 @@ impl Peer {
|
||||
self.state = state;
|
||||
}
|
||||
|
||||
pub fn set_height(&mut self, height: u64) {
|
||||
self.height = height;
|
||||
}
|
||||
|
||||
pub fn is_higher(&self, height: u64) -> bool {
|
||||
self.height > height
|
||||
}
|
||||
|
||||
pub fn is_public(&self) -> bool {
|
||||
self.public
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user