more refactor, not quite done.

This commit is contained in:
John Smith
2022-01-03 23:58:26 -05:00
parent 55a44e0c8f
commit e32984a5aa
19 changed files with 318 additions and 339 deletions
+3 -32
View File
@@ -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!(