Speedup initial blockchain receiving.

This commit is contained in:
Revertron
2021-02-22 12:49:36 +01:00
parent ecb58b9984
commit 803b70fc25
4 changed files with 46 additions and 4 deletions
+10 -1
View File
@@ -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
}