more refactor, not quite done.
This commit is contained in:
@@ -1,37 +1,11 @@
|
||||
use crate::intf::*;
|
||||
use crate::network_connection::*;
|
||||
use crate::xx::*;
|
||||
use crate::*;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct ConnectionTableEntry {
|
||||
pub conn: NetworkConnection,
|
||||
pub established_time: u64,
|
||||
pub last_message_sent_time: Option<u64>,
|
||||
pub last_message_recv_time: Option<u64>,
|
||||
pub stopper: Eventual,
|
||||
}
|
||||
|
||||
impl PartialEq for ConnectionTableEntry {
|
||||
fn eq(&self, other: &ConnectionTableEntry) -> bool {
|
||||
if self.conn != other.conn {
|
||||
return false;
|
||||
}
|
||||
if self.established_time != other.established_time {
|
||||
return false;
|
||||
}
|
||||
if self.last_message_sent_time != other.last_message_sent_time {
|
||||
return false;
|
||||
}
|
||||
if self.last_message_recv_time != other.last_message_recv_time {
|
||||
return false;
|
||||
}
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct ConnectionTable {
|
||||
conn_by_addr: BTreeMap<ConnectionDescriptor, ConnectionTableEntry>,
|
||||
conn_by_addr: BTreeMap<ConnectionDescriptor, NetworkConnection>,
|
||||
}
|
||||
|
||||
impl ConnectionTable {
|
||||
@@ -41,10 +15,7 @@ impl ConnectionTable {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_connection(
|
||||
&mut self,
|
||||
conn: NetworkConnection,
|
||||
) -> Result<ConnectionTableEntry, String> {
|
||||
pub fn add_connection(&mut self, conn: NetworkConnection) -> Result<(), String> {
|
||||
let descriptor = conn.connection_descriptor();
|
||||
|
||||
assert_ne!(
|
||||
|
||||
Reference in New Issue
Block a user