connection table cleanup

This commit is contained in:
John Smith
2022-09-14 14:36:29 -04:00
parent 72b03939ef
commit 8878817961
13 changed files with 401 additions and 352 deletions
+15
View File
@@ -1314,14 +1314,27 @@ impl NetworkManager {
) -> SendPinBoxFuture<EyreResult<NetworkResult<SendDataKind>>> {
let this = self.clone();
Box::pin(async move {
info!("{}", format!("send_data to: {:?}", node_ref).red());
// First try to send data to the last socket we've seen this peer on
let data = if let Some(connection_descriptor) = node_ref.last_connection() {
info!(
"{}",
format!("last_connection to: {:?}", connection_descriptor).red()
);
match this
.net()
.send_data_to_existing_connection(connection_descriptor, data)
.await?
{
None => {
info!(
"{}",
format!("sent to existing connection: {:?}", connection_descriptor)
.red()
);
// Update timestamp for this last connection since we just sent to it
node_ref.set_last_connection(connection_descriptor, intf::get_timestamp());
@@ -1335,6 +1348,8 @@ impl NetworkManager {
data
};
info!("{}", "no existing connection".red());
// If we don't have last_connection, try to reach out to the peer via its dial info
let contact_method = this.get_contact_method(node_ref.clone());
log_net!(